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
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;

using ll = long long;
using ld = long double;

//#define int ll
#define sz(x) ((int)(x).size())

using pii = pair<int,int>;
using tii = tuple<int,int,int>;

const int nmax = 6e5 + 5;
int freq[nmax], weight[nmax];

signed main() {
  cin.tie(0) -> sync_with_stdio(0);
  int n;
  cin >> n;
  map<int,int> fr;
  for(int i = 0, x; i < n; i++) {
    cin >> x;
    fr[x]++;
  }
  for(auto [t, x] : fr)
    freq[x]++,
    weight[x] += x;
  
  for(int i = 1; i <= n * 2; i++) {
    freq[i] += freq[i - 1];
    weight[i] += weight[i - 1];
  }
  
  for(int i = 1; i <= n; i++) {
    int sum = 0;
    for(int j = i; j <= n; j += i)
      sum += (freq[j + i - 1] - freq[j - 1]) * j;
    cout << sum << ' ';
  }
  cout << '\n';
  
}

/**
  Anul asta nu se da centroid
  -- Rugaciunile mele
*/