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

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

    std::unordered_map<int, int> data;
    std::unordered_map<int, int> stats;
    int n, a;

    std::cin >> n;
    std::vector<int> res(n);

    for (int i = 0; i < n; i++)
    {
        std::cin >> a;
        data[a]++;
    }

    for (const auto &[key, val] : data)
    {
        stats[val]++;
    }
    data.clear();

    for (const auto &[key, count] : stats)
    {
        for (int div = 1; div <= key; div++)
        {
            res[div - 1] += (key - key % div) * count;
        }
    }

    for (const auto val : res)
    {
        std::cout << val << ' ';
    }
    std::cout << '\n';
}