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

using namespace std;
using num = int;

vector<num> v;
map<num, num> m;

num binsearch(num x)
{
	num pocz = 0;
	num kon = v.size();
	while (kon - pocz > 1)
	{
		num mid = (pocz + kon) / 2;
		if (v[mid] >= x)
		{
			kon = mid;
		}
		else
		{
			pocz = mid;
		}
	}
	return kon;
}


int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	num n;
	cin >> n;
	for (num i = 0; i < n; ++i)
	{
		num x;
		cin >> x;
		++m[x];
	}
	for (auto it : m)
	{
		v.push_back(it.second);
	}
	v.push_back(numeric_limits<num>::min());
	v.push_back(numeric_limits<num>::max());
	sort(v.begin(), v.end());
	for (num i = 1; i <= n; ++i)
	{
		num sum = 0;
		for (num j = i; j <= n; j += i)
		{
			sum += v.size() - binsearch(j) - 1;
		}
		cout << sum * i << ' ';
	}
	return 0;
}