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
// ZNA: Znaczki pocztowe [C] | 2024-03-12 | Solution by dkgl
// https://sio2.mimuw.edu.pl/c/pa-2024-1/p/zna/

#include <bits/stdc++.h>

using namespace std;

struct QueueItem {
  int count;
  int per_person;
  QueueItem(int _count): count(_count), per_person(_count) {};
  int max_persons() const {
    if (per_person == 0) return INT_MAX;
    return count / per_person;
  };
};
// Lower is less persons
bool operator<(const QueueItem &lhs, const QueueItem &rhs) {
  return lhs.max_persons() > rhs.max_persons();
}

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

  int n;
  cin >> n;
  unordered_map<int, int> value_count;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    value_count[a]++;
  }
  priority_queue<QueueItem> queue;
  int total_per_person = 0;
  for (auto [value, count]: value_count) {
    queue.push(QueueItem(count));
    total_per_person += count;
  }
  for (int persons = 1; persons <= n; ++persons) {
    while (persons > queue.top().max_persons()) {
      auto item = queue.top();
      queue.pop();
      total_per_person -= item.per_person;
      --item.per_person;
      total_per_person += item.per_person;
      queue.push(item);
    }
    cout << persons * total_per_person << ' ';
  }

  cout << endl;
  return 0;
}