1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, i, v;
  cin >> n;
  map< int, int > m, c;
  for (i = n; i-- && cin >> v; ++m[v]) {
  }
  for (map< int, int >::iterator it = m.begin(); it != m.end(); ++it)
    c[it->second]++;
  vector< long > r(1 + n, 0);
  for (map< int, int >::iterator it = c.begin(); it != c.end(); ++it)
    for (i = v = it->first; i; --i)
      r[i] += (long)(it->second) * (v - (v % i));
  char const *delim = "";
  for (i = 1; i <= n; delim = " ")
    cout << delim << r[i++];
  cout << '\n';
}