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
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

const int M = 300005;
int n, res[M];

int32_t main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	map <int, int> c;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		c[a]++;
	}
	for (auto el : c)
		for (int i = 1; i <= el.second; i++)
			res[i] += (el.second / i) * i;
	for (int i = 1; i <= n; i++)
		cout << res[i] << ' ';
}