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
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>

constexpr int max_n = 5e5 + 10;
std::map<int, int> map_in;
int count[max_n];
int output[max_n];

int main()
{
	std::ios_base::sync_with_stdio(0);
	std::cin.tie(0);

	int n;
	std::cin >> n;

	for (int i = 0; i < n; ++i)
	{
		int a;
		std::cin >> a;
		++map_in[a];
	}
	output[0] = n;
	for (auto x : map_in)
	{
		int ai = x.second;
		for (int i = 1; i <= ai; ++i)
		{
			output[i + 1] -= ai / i - ai / (i + 1);
		}
	}

	
	for (int i = 1; i <= n; ++i)
	{
		output[i] += output[i - 1];
		std::cout << output[i] * i << ' ';
	}


			
}