Negotiable

Time limit: 2s Memory limit: 256MB Input: Output:

Task

We denote by MEX\text{MEX} of a sequence of numbers the smallest non-negative integer that does not belong to the sequence. For example, MEX(0,4,4,1,2)=3\text{MEX}(0, 4, 4, 1, 2) = 3 and MEX(1,2,3)=0\text{MEX}(1, 2, 3) = 0.

We call a sequence bb of numbers b1,b2,,bKb_1, b_2, \ldots, b_K x-negotiable\text{x-negotiable} if and only if MEX(b1,b2,,bK)x\text{MEX}(b_1, b_2,\dots,b_K) \leq x.

For a given sequence bb of length KK, consider a sequence of indices 1i1<i2<<is<K1 \leq i_1 < i_2 < \ldots < i_s < K. This sequence determines a division of bb into s+1s+1 consecutive subsequences: (b1,b2,,bi1)(b_{1}, b_2, \ldots, b_{i_1}), (bi1+1,bi1+2,,bi2)(b_{i_1+1}, b_{i_1+2}, \ldots, b_{i_2}), \ldots, (bis+1,bis+2,,bK)(b_{i_s+1}, b_{i_s+2}, \ldots, b_K). We call this division an x-malleable partition\textit{x-malleable partition} if and only if each of the s+1s+1 subsequences is xx-negotiable. We define the size of the partition as the number of subsequences, that is, s+1s + 1.

You are given a sequence aa of NN non-negative integers. Determine, for each value of xx from 11 to NN, the minimum size of an xx-malleable partition of sequence aa.

Input Data

The first line contains the integer NN.
The second line contains NN integers — the elements of sequence AA.

Output data

Print NN integers, separated by spaces, representing the answer for each xx.

Restrictions

  • 1N10000001 \leq N \leq 1\,000\,000.
  • 0aiN0 \leq a_i \leq N.
# Points Restrictions
1 13 1N101 \leq N \leq 10
2 19 There are at most 5050 local minima or maxima.
3 23 0ai100 \leq a_i \leq 10
4 19 1N50001 \leq N \leq 5000.
5 12 1N1000001 \leq N \leq 100\,000
6 14 No additional restrictions.

Local minima are defined as values viv_i with 2iN12 \le i \le N - 1 such that vi1vivi+1v_{i-1} \ge v_i \le v_{i+1}. Local maxima are defined as values viv_i with 2iN12 \le i \le N - 1 such that vi1vivi+1v_{i-1} \le v_i \ge v_{i+1}.

Example

stdin

5
0 1 2 3 0

stdout

3 2 2 11 

Explanation

For x=1x = 1, an optimal partition is [1,1],[2,3],[4,5][1, 1], [2, 3], [4, 5].
For x=2x = 2, an optimal partition is [1,2],[3,5][1, 2], [3, 5].
For x=3x = 3, an optimal partition is [1,3],[4,5][1, 3], [4, 5].
For x=4x = 4, an optimal partition is [1,5][1, 5].
For x=5x = 5, an optimal partition is [1,5][1, 5].

Log in or sign up to be able to send submissions!