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
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using str = string;
#define all(a) a.begin(), a.end()
#define print(a) for (auto elem:a) cout<<elem<<' '; cout<<'\n'
#define segprep(b) resize(1<<((int)ceil(log2(b.size()))+1))

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    scanf("%d", &n);
    vi nums(n);
    for (auto &i:nums) scanf("%d", &i);
    nums.push_back((ll)-1);
    sort(all(nums));
    vi counts;
    counts.reserve(n);
    for (int i = 1; i <= n; i++){
        if (nums.at(i) != nums.at(i-1)) counts.push_back(1);
        else counts.back()++;
    }
    counts.shrink_to_fit();
    sort(all(counts));

    int ans;
    for (int k = 1; k <= n; k++){
        ans = 0;
        for (auto i = lower_bound(all(counts), k); i != counts.end(); i++){
            ans += (*i/k)*k;
        }
        printf("%d ", ans);
    }
    printf("\n");
}