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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <algorithm>
#include <bits/stdc++.h>
#include <iterator>

using namespace std;

int n;

void renumber(vector<int> &v) {
  sort(v.begin(), v.end());
  int prev = -1, idx = 0;
  for (int &x : v) {
    if (x > prev)
      ++idx;
    prev = x;
    x = idx;
  }
}

vector<int> count_appearences(const vector<int> &v) {
  vector<int> unfiltered(n + 1, 0);
  for (const int x : v)
    ++unfiltered[x];

  vector<int> res;
  copy_if(unfiltered.begin(), unfiltered.end(), back_inserter(res),
          [](int x) { return x; });

  return res;
}

const vector<int> factors(const int x) {
  vector<int> res = {1, x};
  int d;
  for (d = 2; d * d < x; ++d) {
    if (x % d == 0) {
      res.push_back(d);
      res.push_back(x / d);
    }
  }
  if (d * d == x)
    res.push_back(d);
  return res;
}

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

  cin >> n;
  vector<int> v(n);
  for (int &i : v)
    cin >> i;
  renumber(v);

  vector<int> cnts = count_appearences(v);
  vector<int> res(n + 1, 0);

  for (const int x : cnts)
    for (int i = 1; i <= x; ++i)
      res[i] += x - (x % i);

  for (int i = 1; i <= n; ++i)
    cout << res[i] << ' ';
  cout << '\n';
}