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
64
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

ll binSearch(vector<ll> &a, ll x) {
    ll l = 0;
    ll r = a.size() - 1;
    while (l < r) {
        ll mid = (l + r) / 2;
        if (a[mid] < x) {
            l = mid + 1;
        }else {
            r = mid;
        }
    }
    return l;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    cin >> n;
    unordered_map<ll, ll> count;
    vector<ll> keys;
    for (ll i = 0; i < n; i++) {
        ll x;
        cin >> x;
        if(count.count(x) == 0) {
            count[x] = 1;
            keys.push_back(x);
        }else {
            count[x]++;
        }
    }
    vector<ll> a;
    a.push_back(0);
    for (ll key : keys) {
        a.push_back(count[key]);
    }
    sort(a.begin(), a.end());
    cout << n << " ";
    for (ll k = 2; k <= n; k++) {
        ll ans = 0;
        ll maks = a.back();
        ll x = maks / k;
        ll end = a.size();
        ll start = binSearch(a, k*x);
        ans += (end - start) * k*x;
        x--;
        while(x>0) {
            end = start;
            start = binSearch(a, k*x);
            ans += (end - start) * k*x;
            x--;
        }
        cout << ans << " ";
    }

}