Problem:
Score : 600 points

Problem Statement

Takahashi has N cards. The i-th of these cards has an integer A_i written on it.

Takahashi will choose an integer K, and then repeat the following operation some number of times:

Choose exactly K cards such that the integers written on them are all different, and eat those cards. (The eaten cards disappear.)

For each K = 1,2, \ldots, N, find the maximum number of times Takahashi can do the operation.

Constraints

1 \le N \le 3 \times 10^5

1 \le A_i \le N

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \ldots A_N

Output

Print N integers.
The t-th (1 \le t \le N) of them should be the answer for the case K=t.

Sample Input 1

3
2 1 2

Sample Output 1

3
1
0

For K = 1, we can do the operation as follows:

Choose the first card to eat.

Choose the second card to eat.

Choose the third card to eat.

For K = 2, we can do the operation as follows:

Choose the first and second cards to eat.

For K = 3, we cannot do the operation at all. Note that we cannot choose the first and third cards at the same time.

Sample Input 2

5
1 2 3 4 5

Sample Output 2

5
2
1
1
1

Sample Input 3

4
1 3 3 3

Sample Output 3

4
1
0
0

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {
		long startTime = System.currentTimeMillis();
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); // 3e5
		int[] A = new int[N];
		int[] cnt = new int[N];
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextInt();
			--A[i];
			++cnt[A[i]];
		}
		class Pair {
			long height;
			long duplicate;

			public Pair(long height, long duplicate) {
				this.height = height;
				this.duplicate = duplicate;
			}
		}
		Arrays.sort(cnt);
		ArrayDeque<Pair> dq = new ArrayDeque<>();
		int sz = 0;
		for (int i = 0; i < cnt.length; ++i) {
			if (cnt[i] == 0)
				continue;
			int j = i;
			while (j + 1 < cnt.length && cnt[i] == cnt[j + 1])
				++j;
			dq.addLast(new Pair(cnt[i], j - i + 1));
			sz += j - i + 1;
			i = j;
		}
		dq.addLast(new Pair((long) 1e6, 1));
		long[] ans = new long[N + 1];
		PrintWriter pw = new PrintWriter(System.out);
		long res = 0;
		for (int K = N; K >= 1; --K) {
			if (K > sz)
				continue;
			while (res > 0) {
				if (dq.size() >= 2) {
					Pair p1 = dq.pollFirst();
					Pair p2 = dq.pollFirst();
					if (p1.duplicate * (p2.height - p1.height) <= res) {
						res -= p1.duplicate * (p2.height - p1.height);
						p2.duplicate += p1.duplicate;
						dq.addFirst(p2);
						continue;
					} else if (p1.duplicate <= res) {
						p1.height += res / p1.duplicate;
						res %= p1.duplicate;
						dq.addFirst(p2);
						dq.addFirst(p1);
					} else if (p1.duplicate > res) {
						long d0 = p1.duplicate;
						p1.duplicate = d0 - res;
						Pair p = new Pair(p1.height + 1, res);
						if (p.height == p2.height) {
							p2.duplicate += p.duplicate;
							dq.addFirst(p2);
						} else {
							dq.addFirst(p2);
							dq.addFirst(p);
						}
						dq.addFirst(p1);
						res = 0;
					}
				} else if (dq.size() == 1) {
					throw new AssertionError();
				}
			}
			res += dq.peek().height;
			ans[K] = dq.peek().height;
			dq.peek().duplicate--;
			if (dq.peek().duplicate == 0)
				dq.poll();
		}
		for (int i = 1; i <= N; ++i) {
			pw.println(ans[i]);
		}
		pw.close();
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}