我们定义一个集合的 mex 是最小的不在 S 中的非负整数。
给定一个序列 a1,…,an,对于每个 1≤k≤n,我们按照如下方式定义 bk:
- 对于 a 的所有长为 k 的子区间,求出这个子区间构成的数集的 mex。
- 对于求出的所有 mex,求出这个数集自己的 mex,记为 bk。
请你求出序列 b。
We define mex of a set S to be the smallest non-negative integer not in S.
Given a sequence a1,…,an, for each 1≤k≤n, we define bk as follows:
- For all subintervals of a of length k, find the mex of the set of numbers formed by this subinterval.
- For all mex found, find mex of the set of numbers itself, denoted bk.
Find the sequence b.
输入
第一行输入一个正整数 n(1≤n≤105)。
第二行输入 n 个整数 a1,…,an(0≤ai≤n)。
The first line enters a positive integer n (1≤n≤105).
The second line enters n integers a1,…,an (0≤ai≤n).
输出
一行输出 n 个整数 b1,…,bn。
A line outputs n integers b1,…,bn.
样例
标准输入 复制文本 |
6
0 0 0 1 2 3
|
标准输出 复制文本 |
2 3 4 0 0 0
|