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 <iostream>
#include <unordered_map>

void solve() {
    int n;
    std::cin >> n;
    std::unordered_map<int, int> stamps;
    for (int i = 0; i < n; i++) {
        int x;
        std::cin >> x;
        stamps[x]++;
    }

    std::unordered_map<int, int> cnt;
    int max = 0;
    for (auto [_, c] : stamps) {
        cnt[c]++;
        max = std::max(max, c);
    }

    for (int i = 1; i <= max; i++) {
        int sum = 0;
        for (auto [a, b] : cnt) sum += b * (a - a%i);
        std::cout << sum << ' ';
    }

    for (int i = max + 1; i <= n; i++) std::cout << "0 ";
    std::cout << "\n";
}

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

    solve();

    return 0;
}