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
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

#define MAX_N 300005

#ifndef DEB_VAL
  #define DEB_VAL 0
#endif
#define DEB if(debug)

#define MP make_pair
#define PB push_back
#define FT first
#define SD second

int debug = DEB_VAL;

long long tab[MAX_N];
int c[MAX_N];
int res[MAX_N];
int n;

int main() {
  scanf("%d", &n);
  for(int i=0;i<n;i++) {
    scanf("%lld", tab+i);
  }
  sort(tab, tab+n);
  //liczymy ilosci
  int akt=tab[0];
  int counter=1;
  for(int i=1;i<n;i++) {
    if(tab[i]==akt) counter++;
    else {
      c[counter]++;
      counter=1;
      akt=tab[i];
    }
  }
  c[counter]++;
  for(int i=n;i>0;i--) {
    if(c[i]>0) {
      akt=1;
      while(i/akt>0) {
        res[akt]+=(i/akt)*c[i];
        akt++;
      }
    }
  }
  for(int i=1;i<=n;i++) {
    printf("%d", res[i]*i);
    if(i<n) printf(" ");
    else printf("\n");
  }
  return 0;
}