1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <bits/stdc++.h>

#define ll long long
#define fors(u, n, s) for(ll u = (s); u < (n); u++)
#define foru(u, n) fors(u, n, 0)
#define vec vector
#define pb push_back
#define f first
#define s second
#define ir(a, b, x) (((a) <= (x)) && ((x) <= (b)))
#define pint pair<ll, ll>

using namespace std;

const int N = 4e5;
int n;

vec<int> cnt;

int prfx[N];

int almost_sqrt(int x){
	int a = 1;
	int b = 1e3;

	while(a != b-1){
		int m = (a+b)/2;
		if(m*(m-1) < x) a = m;
		else b = m;
	}

	return a;
}


int main(){

	cin >> n;

	map<int, int> m;
	foru(i, n) {
		int x; cin >> x;
		m[x]++;
	}

	for(auto i : m){
		cnt.pb(i.s);
	}

	for(auto i : cnt){
		int d = almost_sqrt(i) + 10; // +10 for good measure :):):)

		prfx[1] += i;
		fors(j, d+1, 2) {
			prfx[j] += (i/j) - (i/(j-1));
		}

		int val = i/d - 1;
		while(val >= 0) {
			int idx = i/(val+1) + 1;
			prfx[idx] --;
			val --;
		}
	}

	int sum = 0;
	fors(i, n+1, 1) {
		sum += prfx[i];
		cout << sum*i << " ";
	}
	
	return 0;
}