PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SRD0000069. Cho đến khi tôi gục ngã (Till I Collapse)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Cho đến khi tôi gục ngã (Till I Collapse)

Till I Collapse

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

For every k=1,2,…,nk=1,2,\ldots,n, partition the entire array of colors into the minimum number of nonempty contiguous segments, with at most kk distinct values in each segment. Every element must belong to exactly one segment.

Input

Read nn and the nn colors. There is no query section.

Output

Print nn integers on one line, one minimum partition count for each k=1,2,…,nk=1,2,\ldots,n.

Subtasks

  • Subtask 1 (10 points): 1≤n≤401\le n\le 40. 1≤ai≤n1\le a_i\le n.
  • Subtask 2 (20 points): 1≤n≤20001\le n\le 2000. 1≤ai≤n1\le a_i\le n.
  • Subtask 3 (30 points): 1≤n≤200001\le n\le 20000. 1≤ai≤n1\le a_i\le n.
  • Subtask 4 (40 points): 1≤n≤1000001\le n\le 100000. 1≤ai≤n1\le a_i\le n.

Examples

Input

5
1 3 4 3 3

Output

4 2 1 1 1

Explanation

For k=1k=1, a minimum partition is [1],[3],[4],[3,3][1],[3],[4],[3,3] (four segments). For k=2k=2, [1],[3,4,3,3][1],[3,4,3,3] uses two. For any k≥3k\ge3, all elements fit into a single segment.