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
#include <bits/stdc++.h>
#define ll long long
#define llu long long unsigned
#define ld long double
#define fr(i,n) for(int i=0;i<n;i++)
#define watch(x) cout<<(#x)<<"=="<<(x)<<endl
#define ft first
#define sc second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define P 1000000007llu
#define N 300005
#define M 1000001
#define LC 262144
using namespace std;

int getchar_pos_int() {
    int n=0, c=getchar();
    while('0'<=c&&c<='9') {n=n*10+c-'0'; c=getchar();}
    return n;
}

int a[N],n,stampsPerPerson,res[N];
vi frequencies;

void getFrequencies() {
    int currFreq=1;
    for(int i=1;i<n;i++) {
        if(a[i]!=a[i-1]) {
            frequencies.pb(currFreq);
            currFreq=1;
        } else currFreq++;
    }
    frequencies.pb(currFreq);
}

int main() {
    n=getchar_pos_int();
    fr(i,n) a[i]=getchar_pos_int();
    sort(a,a+n);
    getFrequencies();
    sort(frequencies.begin(),frequencies.end());
    reverse(frequencies.begin(),frequencies.end());
    for(int freq: frequencies) {
        for(int k=1;k<=n;k++) {
            stampsPerPerson=freq/k;
            if(stampsPerPerson==0) break;
            res[k]+=stampsPerPerson*k;
        }
    }
    for(int k=1;k<=n;k++) printf("%d ",res[k]);
    return 0;
}