Problem:
Score : 600 points

Problem Statement

Takahashi has N cards. The i-th of these cards has an integer A_i written on it.

Takahashi will choose an integer K, and then repeat the following operation some number of times:

Choose exactly K cards such that the integers written on them are all different, and eat those cards. (The eaten cards disappear.)

For each K = 1,2, \ldots, N, find the maximum number of times Takahashi can do the operation.

Constraints

1 \le N \le 3 \times 10^5

1 \le A_i \le N

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \ldots A_N

Output

Print N integers.
The t-th (1 \le t \le N) of them should be the answer for the case K=t.

Sample Input 1

3
2 1 2

Sample Output 1

3
1
0

For K = 1, we can do the operation as follows:

Choose the first card to eat.

Choose the second card to eat.

Choose the third card to eat.

For K = 2, we can do the operation as follows:

Choose the first and second cards to eat.

For K = 3, we cannot do the operation at all. Note that we cannot choose the first and third cards at the same time.

Sample Input 2

5
1 2 3 4 5

Sample Output 2

5
2
1
1
1

Sample Input 3

4
1 3 3 3

Sample Output 3

4
1
0
0

Solution in C (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int A[300001], B[300001];

// ヒープソート (Start) *****************
//#define UP     // 昇順のときdefine, 降順のときマスク
//#define SLAVE  // 従属配列がある場合にdefineする
int *M_ARRAY;
int *S_ARRAY;
int TMP;

void swap(int i, int j) {
    int TMP;
    TMP        = M_ARRAY[i];
    M_ARRAY[i] = M_ARRAY[j];
    M_ARRAY[j] = TMP;
#ifdef SLAVE
    TMP        = S_ARRAY[i];
    S_ARRAY[i] = S_ARRAY[j];
    S_ARRAY[j] = TMP;
#endif
}

void heap(int k, int r) {
    int j;
    while (1) {
        j = 2 * k + 1;
        if (j > r) break;
        if (j != r) {
#ifdef UP
            if (M_ARRAY[j + 1] > M_ARRAY[j]) {
#else
            if (M_ARRAY[j + 1] < M_ARRAY[j]) {
#endif
                j = j + 1;
            }
        }
#ifdef UP
        if (M_ARRAY[k] >= M_ARRAY[j]) break;
#else
        if (M_ARRAY[k] <= M_ARRAY[j]) break;
#endif
        swap(k, j);
        k = j;
    }
}

void sort(int length) {
    int i;
    for (i = (length - 2) / 2; i >= 0; i--) {
        heap(i, length - 1);
    }
    for (i = length - 1; i > 0; i--) {
        swap(0, i);
        heap(0, i - 1);
    }
}

// ***************** ヒープソート (End)


int main() {
  unsigned int N, result;
  int i, j, k, M, m, max;
  scanf ("%d", &N);
  
  for (i=0;i<N;i++) {
      scanf("%d", &B[i]);
  }
  
  M_ARRAY = B;
  sort(N);
  

  
  M=0;
  A[0]=1;
  for (i=1;i<N;i++) {
    if (B[i]==B[i-1]) A[M]++;
    else {M++; A[M]=1;}
  }
  M++;
  for (i=M;i<N;i++) A[i] = 0;
  
  M_ARRAY = A;
  sort(M);
  
  for (i=0;i<N;i++) B[i]=A[i];
  
  for (i=0;i<N;i++) {
    result = 0;
    for (j=0;j<M;j++) A[j]=B[j];
    m = M;

    while (1) {
      if (A[i]==0) {printf("%d\n", result); break;}
      
      if (A[i]==1) {
        max = (m - (i+1)) / (i+1);
        for (j=0;j<i;j++) if (A[j]<=max) {m-=max-A[j]; A[j]=0;}
                          else                         A[j]-=max;
        result+=max;
        sort(m);
        for (j=m-1;j>0;j--) if (A[j]!=0) {m=j+1; break;}
      }
      
      
      result += A[i];
      for (j=0;j<=i;j++) A[j]-=A[i];
      sort(m);
      for (j=m-1;j>0;j--) if (A[j]!=0) {m=j+1; break;}
      
    }
  }
  
  return 0;
}