Loading [MathJax]/jax/output/CommonHTML/jax.js
Sequence division - MarisaOJ: Marisa Online Judge

Sequence division

Time limit: 1000 ms
Memory limit: 256 MB

Alice has a sequence of non-negative integers a1,a2,…,an and defines a partitioning of the sequence into k segments (l1,r1),(l2,r2),…,(lk,rk) as an x-beautiful partition if it satisfies:

  • Each position i (1≤i≤n) belongs to exactly one segment. Specifically, there exists exactly one segment (lt,rt) such that lt≤i≤rt;
  • The smallest non-negative integer that does not appear in each consecutive subarray alt,alt+1,…,art does not exceed x.

Objective: Given a sequence of n non-negative integers, help Alice determine, for each value x (0≤x≤n−1), the minimum number of segments k in an x-beautiful partition.

Input

  • The first line contains an integer n (1≤n≤106);
  • The second line contains n non-negative integers ai (0≤ai≤106).

Output

  • Print n lines, each corresponding to the result of the x-beautiful partition with x from 0 to n−1. If there is no satisfying partition, print -1.

Example

Input:

5 
2 0 1 0 3

Output:

-1 
3 
2 
2 
1

Subtasks

  • Subtask 1 (20 points): n≤100.
  • Subtask 2 (20 points): n≤3000.
  • Subtask 3 (20 points): n≤2×105.
  • Subtask 4 (20 points): k≤20 for all 0≤x≤n−1.
  • Subtask 5 (20 points): No additional constraints.