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 <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#define REP(x,n) for (int x=0;x<(n);++x)
#define VAR(x,n) __typeof(n) x = (n)
#define FOREACH(x,c) for(VAR(x,(c).begin()); x != (c).end(); ++x)
//#define __DEBUG

#define MAX_N 300001

using namespace std;

int n,i;
map<int,int> occurrencesByCity;
map<int,int> occurrencesGroups;

void solve() {
        cin >> n;
    REP(x,n) {
        cin>>i;
        ++occurrencesByCity[i];
    }
    FOREACH(it, occurrencesByCity) {
        ++occurrencesGroups[it->second];
    }
#ifdef __DEBUG
    FOREACH(it, occurrencesGroups) {
        cerr << it->first << " -> " << it->second << endl;
    }
#endif
    
    int sequences = 0;
    int leftItems = n;
    int i = 0;
    while (++i <= n) {
        int sum = 0;
        FOREACH(it, occurrencesGroups)
            sum += (it->first/i) * it->second;
        cout << i * sum << " ";
        if (sum == 0)
            break;
    }
    while (++i <= n) {
        cout << "0 ";
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    solve();
    
    return 0;
}