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
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
const ll LINF = 1e18;
const int INF = 1e9;

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

    int n;
    cin >> n;
    vi a(n);
    unordered_map<int, int> cnt;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        cnt[a[i]] += 1;
    }

    vi result(n + 1);
    for (auto &el: cnt) {
        int el_cnt = el.second;
        for (int i = 1; i <= el_cnt; ++i) {
            result[i] += (el_cnt / i) * i;
        }
    }

    for (int i = 1; i <= n; ++i) {
        cout << result[i] << ' ';
    }
    cout << endl;

    return 0;
}