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
//2024-03-12
//author: Marcin Rolbiecki
#include <bits/stdc++.h>
using namespace std;

const int maxN = 3e5+2;
int a[maxN], ans[maxN];
map <int, int> ile;
int n;

int main ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 1; i <= n; i++) 
	{
		cin >> a[i];
		ile[ a[i] ]++;
	}
	
	for (auto p : ile)
	{
		int z = p.second;
		for (int i = z; i >= 1; i--)
			ans[i] += (z/i) * i;
	}
	
	for (int i = 1; i <= n; i++)
		cout << ans[i] << ' ';
	
	return 0;
}