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

using namespace std;

const int MAX_N = 300001;
int res[MAX_N];
map<int, int> inp;


int main()
{
    int n;
    cin >> n;
    int x;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        inp[x]++;
    }
    
    for (const auto& [key, value] : inp) {
        for (int i = 1; i <= value; i++) {
            res[i] += i * (value / i); 
        }
    }
    
    for (int i = 1; i <= n; i++) {
        cout << res[i] << " ";
    }
    return 0;
}