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
#include<bits/stdc++.h>
using namespace std;

constexpr int base = 1 << 19;
vector<int> arr;
vector<int> tree[(base << 1) + 2];

void update(int a, int b, int val){
	a = a + base - 1;
	b = b + base + 1;
	while((a >> 1) != (b >> 1)){
		if(!(a & 1)) tree[a + 1].push_back(val);
		if(b & 1) tree[b - 1].push_back(val);
		a = a >> 1;
		b = b >> 1;
	}
}

int C(int indx, int d){
	int ans = 0;
	for(auto x : tree[indx]) ans += ((x / d) * d);
	return ans;
}

int query(int a){
	int ans = 0, i = a;
	a += base;
	while(a){
		ans += C(a, i);
		a = a >> 1;
	}
	return ans;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		arr.push_back(x);
	}
	sort(arr.begin(), arr.end());
	arr.push_back(-1);
	int ile = 1, m = 0;
	for(int i = 1; i < arr.size(); i++){
		if(arr[i - 1] == arr[i]) ile++;
		else{
			update(1, ile, ile);
			m = max(m, ile);
			ile = 1;
		}
	}
	for(int i = 1; i <= n; i++){
		if(i <= m) cout << query(i) << " ";
		else cout << 0 << " ";	
	}
	return 0;
}