
Task
We denote by 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 and MEX(1,2,3)=0.
We call a sequence b of numbers b1,b2,…,bK x-negotiable if and only if MEX(b1,b2,…,bK)≤x.
For a given sequence b of length K, consider a sequence of indices 1≤i1<i2<…<is<K. This sequence determines a division of b into s+1 consecutive subsequences: (b1,b2,…,bi1), (bi1+1,bi1+2,…,bi2), …, (bis+1,bis+2,…,bK). We call this division an x-malleable partition if and only if each of the s+1 subsequences is x-negotiable. We define the size of the partition as the number of subsequences, that is, s+1.
You are given a sequence a of N non-negative integers. Determine, for each value of x from 1 to N, the minimum size of an x-malleable partition of sequence a.
The first line contains the integer N.
The second line contains N integers — the elements of sequence A.
Output data
Print N integers, separated by spaces, representing the answer for each x.
Restrictions
- 1≤N≤1000000.
- 0≤ai≤N.
| # |
Points |
Restrictions |
| 1 |
13 |
1≤N≤10 |
| 2 |
19 |
There are at most 50 local minima or maxima. |
| 3 |
23 |
0≤ai≤10 |
| 4 |
19 |
1≤N≤5000. |
| 5 |
12 |
1≤N≤100000 |
| 6 |
14 |
No additional restrictions. |
Local minima are defined as values vi with 2≤i≤N−1 such that vi−1≥vi≤vi+1. Local maxima are defined as values vi with 2≤i≤N−1 such that vi−1≤vi≥vi+1.
Example
stdin
5
0 1 2 3 0
stdout
3 2 2 11
Explanation
For x=1, an optimal partition is [1,1],[2,3],[4,5].
For x=2, an optimal partition is [1,2],[3,5].
For x=3, an optimal partition is [1,3],[4,5].
For x=4, an optimal partition is [1,5].
For x=5, an optimal partition is [1,5].