AtCoder Beginner Contest 143 - Distinct Numbers

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-----
3
2 1 2

-----Sample Output-----
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.

Difficulty: MEDIUM_HARD

Starter code:

Solutions:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = list(Counter(a).values())
c.sort()
ans = n
cnt = 0
for i in range(n):
	m = i + 1 - cnt
	while c and c[-1] > ans // m:
		ans -= c.pop()
		cnt += 1
		m -= 1
	print(ans // m)


import bisect
n = int(input())
a = list(map(int, input().split()))
c = [0] * (n + 1)
for i in range(n):
	c[a[i]] += 1
d = [0] * (n + 1)
for i in range(n + 1):
	d[c[i]] += 1
sum1 = 0
sum2 = sum(d) - d[0]
fx = []
for x in range(1, n + 1):
	sum1 += x * d[x]
	sum2 -= d[x]
	fx.append((sum1 + x * sum2) // x)
fx.sort()
for i in range(1, n + 1):
	j = bisect.bisect_left(fx, i)
	print(n - j)


import sys
import collections

def solve(N: int, A: 'List[int]'):
	counter = sorted(list(collections.Counter(A).values()), reverse=True)
	c_index = 0
	k = 0
	for i in range(1, N + 1):
		k += 1
		if len(counter) < i:
			print(0)
			continue
		while counter[c_index] * k > N and c_index < len(counter) - 1:
			N -= counter[c_index]
			c_index += 1
			k -= 1
		print(N // k)
	return

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	N = int(next(tokens))
	A = [int(next(tokens)) for _ in range(N)]
	solve(N, A)

def __starting_point():
	main()
__starting_point()


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import time, random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	n = I()
	c = sorted(collections.Counter(LI()).values(), reverse=True) + [0]
	ci = 0
	t = n
	r = [0]
	for i in range(n, 0, -1):
		while c[ci] > i:
			ci += 1
		t -= ci
		r.append(t // i)
	rr = []
	r.reverse()
	ri = 0
	for i in range(n, 0, -1):
		while r[ri] >= i:
			ri += 1
		rr.append(ri)
	rr.reverse()
	return JA(rr, '\n')
print(main())


def main():
	input()
	cards = list(map(int, input().split()))
	counts = [0] * len(cards)
	values = [0] * len(cards)
	for c in cards:
		c -= 1
		values[counts[c]] += 1
		counts[c] += 1
	lengths = []
	used = 0
	for (i, v) in enumerate(values):
		used += v
		lengths.append(used // (i + 1))
	number = len(lengths) - 1
	for k in range(1, len(cards) + 1):
		while number >= 0 and lengths[number] < k:
			number -= 1
		print(number + 1)
main()


N = int(input())
A = list(map(int, input().split()))
c = [0] * (N + 1)
Dx = [0] * (N + 1)
for a in A:
	c[a] += 1
	Dx[c[a]] += 1
Sx = [0]
for j in range(1, N + 1):
	Sx.append(Sx[j - 1] + Dx[j])
for h in range(1, N + 1):
	Sx[h] = Sx[h] / h
x = N
k = 1
while k < N + 1:
	if x < 0:
		for _ in range(N - k + 1):
			print(0)
		exit(0)
	if k <= Sx[x]:
		print(x)
		k += 1
	else:
		x -= 1


import sys
sys.setrecursionlimit(2147483647)
INF = float('inf')
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().rstrip()

def resolve():
	from collections import Counter
	n = int(input())
	A = list(Counter(map(int, input().split())).values())
	A.sort()
	m = len(A)
	S = [0] * (m + 1)
	for i in range(m):
		S[i + 1] = S[i] + A[i]
	p = n
	i = m
	from bisect import bisect_left
	for k in range(1, n + 1):
		while 1:
			while 1:
				if i <= 0 or A[i - 1] < p:
					break
				i -= 1
			if S[i] + p * (m - i) >= k * p:
				break
			p -= 1
		print(p)
resolve()


def main():
	N = int(input())
	A = list(map(int, input().split()))
	C = [0] * (N + 1)
	D = [0] * (N + 1)
	for a in A:
		C[a] += 1
		D[C[a]] += 1
	S = [0] * (N + 1)
	f = [0] * (N + 1)
	for x in range(1, N + 1):
		S[x] = S[x - 1] + D[x]
		f[x] = S[x] // x
	ans = []
	prev_ans = N
	for K in range(1, N + 1):
		a = prev_ans
		while True:
			if f[a] >= K or a == 0:
				break
			a -= 1
		ans.append(a)
		prev_ans = a
	print(*ans, sep='\n')

def __starting_point():
	main()
__starting_point()


from collections import Counter
n = int(input())
c = list(Counter((ai for ai in map(int, input().split()))).values())
c.sort()
clen = len(c)
s = [0] * (clen + 1)
for i in range(clen):
	s[i + 1] = s[i] + c[i]
for i in range(1, n + 1):
	rest = clen - i
	if rest < 0:
		print(0)
		continue
	l1 = 0
	r1 = s[clen] // i + 2
	while r1 - l1 > 1:
		c1 = (l1 + r1) // 2
		l2 = -1
		r2 = clen
		while r2 - l2 > 1:
			c2 = (r2 + l2) // 2
			if c[c2] < c1:
				l2 = c2
			else:
				r2 = c2
		if (r2 - rest) * c1 <= s[r2]:
			l1 = c1
		else:
			r1 = c1
	print(l1)


from collections import Counter
from itertools import accumulate

def bisect(ng, ok, judge):
	while abs(ng - ok) > 1:
		m = (ng + ok) // 2
		if judge(m):
			ok = m
		else:
			ng = m
	return ok
N = int(input())
A = Counter(Counter(map(int, input().split())).values())
m = max(A.keys())
nA = list(accumulate((A[c] for c in range(m + 1))))
wA = list(accumulate((A[c] * c for c in range(m + 1))))
A = [wA[i] + (nA[-1] - nA[i]) * i for i in range(m + 1)]
for k in range(1, N + 1):
	print(bisect(N + 1, 0, lambda x: x * k <= A[min(x, m)]))


N = int(input())
A = map(int, input().split())
C = [0] * N
for a in A:
	C[a - 1] += 1
D = [0] * (N + 1)
for c in C:
	D[c] += 1
Dk_accum = [0] * (N + 1)
for i in range(1, N + 1):
	Dk_accum[i] = Dk_accum[i - 1] + i * D[i]
D_sum = sum(D)
D_accum = [0] * (N + 2)
D_accum[0] = D_sum
for i in range(1, N + 1):
	D_accum[i] = D_accum[i - 1] - D[i - 1]
F = [0] * (N + 1)
for i in range(1, N + 1):
	F[i] = Dk_accum[i] // i + D_accum[i + 1]
i = N
for K in range(1, N + 1):
	while i > 0 and K > F[i]:
		i -= 1
	print(i)


from collections import Counter

def main():
	N = int(input())
	A = list(map(int, input().split()))
	m = max(list(Counter(A).values()))
	d = Counter(Counter(A).values())
	l = []
	t = 0
	for i in range(m, 0, -1):
		t += d[i]
		l.append(t)
	l.reverse()
	t = 0
	r = []
	for i in range(N):
		if m > i:
			t += l[i]
		r.append(t // (i + 1))
	p = -1
	a = []
	for (i, v) in enumerate(reversed(r)):
		if p != v:
			a.append((v, N - i))
		p = v
	a.append((N, 0))
	t = 0
	aa = []
	for i in range(1, N + 1):
		if a[t][0] < i:
			t += 1
		aa.append(a[t][1])
	for i in aa:
		print(i)
main()


import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
from collections import Counter
from itertools import accumulate
import bisect
C = Counter(A)
LIST = sorted(C.values())
LEN = len(LIST)
SUM = [0] + list(accumulate(LIST))
MIN = 0
MAX = SUM[-1]
for k in range(1, N + 1):
	MIN = 0
	while MIN != MAX:
		mid = (MIN + MAX + 1) // 2
		x = bisect.bisect_right(LIST, mid)
		if SUM[x] + (LEN - x) * mid >= mid * k:
			MIN = mid
		else:
			MAX = mid - 1
	print(MIN)


import sys
sys.setrecursionlimit(2147483647)
INF = float('inf')
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().rstrip()

def bin_sort(A, n_min=None, n_max=None):
	if n_min is None:
		n_min = min(A)
	if n_max is None:
		n_max = max(A)
	bin = [0] * (n_max - n_min + 1)
	for a in A:
		bin[a - n_min] += 1
	B = []
	for i in range(n_min, n_max + 1):
		for _ in range(bin[i - n_min]):
			B.append(i)
	return B

def resolve():
	n = int(input())
	A = [0] * n
	for a in map(int, input().split()):
		A[a - 1] += 1
	A = bin_sort(A, 0, n)
	S = [0] * (n + 1)
	for i in range(n):
		S[i + 1] = S[i] + A[i]
	p = n
	i = n
	for k in range(1, n + 1):
		while 1:
			while 1:
				if i <= 0 or A[i - 1] < p:
					break
				i -= 1
			if S[i] + p * (n - i) >= k * p:
				break
			p -= 1
		print(p)
resolve()


import bisect
N = int(input())
A = list(map(int, input().split()))
D = {}
for i in range(N):
	if A[i] not in D:
		D[A[i]] = 1
	else:
		D[A[i]] += 1
D[0] = 0
D = list(D.values())
D.sort()
B = [D[0]]
for i in range(1, len(D)):
	B.append(B[-1] + D[i])
D = D + [10 ** 15]
cnt = N
for i in range(1, N + 1):
	for j in range(N + 1):
		C = bisect.bisect_left(D, cnt + 0.1)
		if i * cnt <= B[C - 1] + cnt * (len(B) - 1 - C + 1):
			print(cnt)
			break
		else:
			cnt -= 1


import sys
input = sys.stdin.readline
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = sorted(list(Counter(A).values()), reverse=True)
L = len(C)
B = []
num = C[0]
for (i, c) in enumerate(C):
	for _ in range(num - c):
		B.append(i)
	num = c
for _ in range(num):
	B.append(L)
ans = [N]
for n in range(2, N + 1):
	if n > L:
		ans.append(0)
		continue
	count = 0
	stack = []
	for b in B:
		tmp = b
		while stack:
			if tmp >= n:
				last = stack.pop()
				tmp = tmp + last - n
				count += 1
			else:
				break
		count += tmp // n
		stack.append(tmp % n)
	ans.append(count)
print(*ans, sep='\n')


import bisect

def main():
	N = int(input())
	A = list(map(int, input().split()))
	cntA = dict()
	for a in A:
		cntA[a] = cntA.get(a, 0) + 1
	cnt = dict()
	for a in cntA:
		cnt[cntA[a]] = cnt.get(cntA[a], 0) + 1
	sum1 = [0]
	for i in range(1, N + 1):
		if i in cnt:
			sum1.append(sum1[-1] + i * cnt[i])
		else:
			sum1.append(sum1[-1])
	sum2 = [0]
	for i in range(N, -1, -1):
		if i in cnt:
			sum2.append(sum2[-1] + cnt[i])
		else:
			sum2.append(sum2[-1])
	sum2 = sum2[::-1]
	vals = []
	for i in range(1, N + 1):
		v = (sum1[i] + i * sum2[i + 1]) // i
		vals.append(v)
	vals = vals[::-1]
	for i in range(1, N + 1):
		j = bisect.bisect_left(vals, i)
		print(N - j)
main()


import sys
sys.setrecursionlimit(2147483647)
INF = float('inf')
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().rstrip()

def bisection(l, r, f, left=True, discrete=True):
	eps = 1 if discrete else 10 ** (-8)
	if (not left) ^ f(r):
		return r if left else r + 1
	elif left ^ f(l):
		return l - 1 if left else l
	while r - l > eps:
		h = (l + r) // 2 if discrete else (l + r) / 2
		if (not left) ^ f(h):
			l = h
		else:
			r = h
	return (l + r) / 2 if not discrete else l if left else r
from collections import defaultdict
from bisect import bisect_left

def resolve():
	n = int(input())
	D = defaultdict(int)
	for a in map(int, input().split()):
		D[a] += 1
	D = list(D.values())
	D.sort()
	t = len(D)
	S = [0] * (t + 1)
	for i in range(t):
		S[i + 1] = S[i] + D[i]
	k = 0

	def check(t):
		i = bisect_left(D, t)
		score = S[i] + t * (len(D) - i)
		return score >= k * t
	for k in range(1, n + 1):
		print(bisection(0, n // k + 1, check))
resolve()


from collections import Counter
from itertools import accumulate
N = int(input())
As = map(int, input().split())
xs = [0] + sorted([x for x in Counter(As).values()]) + [10 ** 18]
Xs = accumulate(xs)
M = len(xs) - 2
rs = [0] * N
mn = N + 1
for (l, (x, X)) in enumerate(zip(xs[1:], Xs)):
	l = M - l
	k = X // (x + 1) + l + 1
	if x <= X // (k - l):
		k += 1
	for i in range(k, mn):
		rs[i - 1] = X // (i - l)
	mn = min(k, mn)
for r in rs:
	print(r)


from collections import Counter
import bisect
N = int(input())
A = list(map(int, input().split()))
C = list(Counter(A).values())
C.sort()
L = len(C)
D = [L - bisect.bisect_left(C, x) for x in range(N + 1)]
S = [0]
for n in range(1, N + 1):
	S.append(S[-1] + D[n])
T = [x / S[x] for x in range(1, N + 1)]
for K in range(1, N + 1):
	print(bisect.bisect_right(T, 1 / K))


from collections import Counter
N = int(input())
As = list(map(int, input().split()))
cntA = Counter(As)
cntCntA = Counter(list(cntA.values()))
accDs = [cntCntA[0]]
for i in range(1, N + 1):
	accDs.append(accDs[-1] + cntCntA[i])
accKDs = [0]
for i in range(1, N + 1):
	accKDs.append(accKDs[-1] + i * cntCntA[i])
fXs = [0]
for X in range(1, N + 1):
	fXs.append((accKDs[X] + X * (accDs[N] - accDs[X])) // X)
anss = [0] * (N + 1)
for (X, fX) in enumerate(fXs):
	anss[fX] = X
for i in reversed(list(range(N))):
	if anss[i] == 0:
		anss[i] = anss[i + 1]
print('\n'.join(map(str, anss[1:])))


import sys
from collections import Counter
from itertools import accumulate
from collections import defaultdict
INF = float('inf')

def solve(N: int, A: 'List[int]'):
	c = Counter(A)
	d = Counter(c.values())
	d = tuple(accumulate([d[i] for i in range(N, -1, -1)]))[::-1]
	S = [0] * (N + 1)
	for i in range(1, N + 1):
		S[i] = S[i - 1] + d[i]

	def isOK(y):
		return S[y] < K * y

	def binary_search(x):
		ng = -1
		ok = len(x) + 1
		while abs(ok - ng) > 1:
			mid = (ok + ng) // 2
			if isOK(mid):
				ok = mid
			else:
				ng = mid
		return (ng, ok)
	for K in range(1, N + 1):
		(ng, ok) = binary_search(range(N))
		print(ng)
	return

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	N = int(next(tokens))
	A = [int(next(tokens)) for _ in range(N)]
	solve(N, A)
main()


from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
d = defaultdict(lambda : 0)
for a in A:
	d[a] += 1
cant_use = [0] * (N + 1)
for v in d.values():
	for i in range(v):
		cant_use[i] += v - i

def is_ok(i, k):
	return (N - cant_use[i]) / k >= i

def bisect(ng, ok, k):
	while abs(ok - ng) > 1:
		mid = (ok + ng) // 2
		if is_ok(mid, k):
			ok = mid
		else:
			ng = mid
	return ok
for k in range(1, N + 1):
	print(bisect(N + 1, 0, k))


(n, *a) = open(0).read().split()
n = int(n)
a = list(map(int, a))
sum = [0] * -~n
o = [0] * -~n
ct = [0] * -~n
b = []
for i in a:
	ct[i] += 1
for i in range(1, n + 1):
	if ct[i]:
		b.append(i)
b.sort(key=lambda x: ct[x])
for i in range(len(b)):
	sum[i] += (sum[i - 1] if i else 0) + ct[b[i]]
j = len(b) - 1
cnt = 0
for i in range(1, n + 1)[::-1]:
	while j >= 0 and ct[b[j]] >= i:
		cnt += 1
		j -= 1
	o[i] = (sum[j] if j >= 0 else 0) // i + cnt
ans = [0]
j = n
for i in range(1, n + 1):
	while j and o[j] < i:
		j -= 1
	ans.append(j)
print(*ans[1:])


from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
C = list(C.values())
C.sort()
n = len(C)
m = max(C)
S = [0] * (m + 1)
b = 0
for i in range(n):
	c = C[i]
	if b < c:
		for j in range(b + 1, c + 1):
			S[j] = S[j - 1] + (n - i)
		b = c
for i in range(1, N + 1):
	ok = 0
	ng = N + 1
	while ng - ok > 1:
		mid = (ok + ng) // 2
		if S[min(m, mid)] >= mid * i:
			ok = mid
		else:
			ng = mid
	print(ok)


from collections import defaultdict, deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def LS():
	return [list(x) for x in sys.stdin.readline().split()]

def S():
	res = list(sys.stdin.readline())
	if res[-1] == '\n':
		return res[:-1]
	return res

def IR(n):
	return [I() for i in range(n)]

def LIR(n):
	return [LI() for i in range(n)]

def SR(n):
	return [S() for i in range(n)]

def LSR(n):
	return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
	n = I()
	a = LI()
	d = defaultdict(lambda : 0)
	for i in a:
		d[i] += 1
	d = list(d.values())
	q = []
	for i in d:
		heappush(q, i)
	ans = []
	for k in range(n):
		if not q:
			break
		else:
			x = heappop(q)
			ans.append(x)
			while q and x:
				y = heappop(q)
				y += 1
				x -= 1
				heappush(q, y)
	for i in ans[::-1] + [0] * (n - len(ans)):
		print(i)
	return
solve()


import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def readstr():
	return readline().rstrip().decode()

def readstrs():
	return list(readline().decode().split())

def readint():
	return int(readline())

def readints():
	return list(map(int, readline().split()))

def printrows(x):
	print('\n'.join(map(str, x)))
from collections import Counter
from itertools import accumulate
import bisect
n = readint()
a = readints()
b = sorted(Counter(a).values())
exist = len(b)
b = [0] * (n - exist) + b
c = list(accumulate([0] + b))
ans = [n]
for k in range(2, exist + 1):
	l = 0
	r = n // k + 1
	while r - l > 1:
		x = (r + l) // 2
		i = bisect.bisect_left(b, x)
		if c[i] + (n - i) * x >= x * k:
			l = x
		else:
			r = x
	ans.append(l)
printrows(ans + [0] * (n - exist))


import os
import sys
import numpy as np
if os.getenv('LOCAL'):
	sys.stdin = open('_in.txt', 'r')
sys.setrecursionlimit(2147483647)
INF = float('inf')
IINF = 10 ** 18
MOD = 10 ** 9 + 7
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
A = np.array(A, dtype=int)
C = np.bincount(A, minlength=N + 2)
D = np.bincount(C, minlength=N + 2)
ld = (D * np.arange(len(D))).cumsum()
ud = D[::-1].cumsum()[::-1]
X = np.arange(1, N + 1, dtype=int)
L = np.zeros(N + 1, dtype=int)
L[X] = (ld[X] + X * ud[X + 1]) // X
i = len(L) - 1
for k in range(1, N + 1):
	while i > 0 and L[i] < k:
		i -= 1
	print(i)


from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
INF = float('inf')

def LI():
	return list(map(int, sys.stdin.readline().split()))

def I():
	return int(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return sys.stdin.readline().strip()

def IR(n):
	return [I() for i in range(n)]

def LIR(n):
	return [LI() for i in range(n)]

def SR(n):
	return [S() for i in range(n)]

def LSR(n):
	return [LS() for i in range(n)]

def SRL(n):
	return [list(S()) for i in range(n)]

def MSRL(n):
	return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7
n = I()
L = [(0, 0)] + sorted([(k, v) for (k, v) in Counter(Counter(LI()).values()).items()])
m = len(L)
acc = [0] * m
ret = 0
for j in range(m):
	(k, v) = L[j]
	ret += k * v
	acc[j] = ret
v_acc = [0] * m
ret = 0
for l in range(m - 1, -1, -1):
	ret += L[l][1]
	v_acc[l] = ret
v_acc += [0]
for i in range(1, n + 1):
	ok = 0
	ng = n // i + 1
	while ng > ok + 1:
		mid = (ng + ok) // 2
		lower_num = bisect_right(L, (mid, INF))
		if acc[lower_num - 1] + v_acc[lower_num] * mid >= i * mid:
			ok = mid
		else:
			ng = mid
	print(ok)


import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
from collections import Counter
import bisect
l = Counter(A).most_common()
l = [b for (a, b) in l]
M = len(l)
l.sort()
p = sum(l)
maximum_operation = [0] * N
ll = []
for x in reversed(range(1, N + 1)):
	a = bisect.bisect_left(l, x)
	if a == 0:
		b = M * x
		c = 0
	elif a >= M:
		b = 0
		c = p
	else:
		b = (M - a) * x
		c = sum(l[0:a])
	ll.append((b + c) / x)
for K in range(M):
	maximum_operation[K] = N - bisect.bisect_left(ll, K + 1)
for m in maximum_operation:
	print(m)


I = int(input())
from collections import Counter
from itertools import accumulate
As = map(int, input().split())
xs = sorted([x for x in Counter(As).values()]) + [10 ** 18]
Xs = accumulate(xs)

def bsearch(target, min_i, max_i, func):
	if func(max_i) <= target:
		return max_i
	if target < func(min_i):
		return min_i - 1
	index = (max_i + min_i) // 2
	while True:
		if func(index) <= target:
			if target < func(index + 1):
				return index
			(index, min_i) = ((index + 1 + max_i) // 2, index + 1)
			continue
		(index, max_i) = ((index - 1 + min_i) // 2, index - 1)
N = len(xs) - 1
rs = [0] * I
mny = N + 1
for (l, (x, X)) in enumerate(zip(xs[1:], Xs)):
	l += 2
	y = bsearch(0, N - l + 2, N + 1, lambda k: x > X // (k - (N - l + 1)))
	y += 1
	for i in range(y, mny):
		rs[i - 1] = X // (i - (N - l + 1))
	mny = min(y, mny)
for r in rs:
	print(r)


from collections import Counter
N = int(input())
C = list(Counter(map(int, input().split())).values())
C.sort()
rest = N
removed = 0
for K in range(1, N + 1):
	d = K - removed
	while C and C[-1] > rest // d:
		rest -= C[-1]
		C.pop()
		removed += 1
		d -= 1
	print(rest // d)


def main():
	N = int(input())
	A = list(map(int, input().split()))
	C = [0] * (N + 1)
	Cnt_A = [0] * (N + 1)
	for a in A:
		Cnt_A[a] += 1
		cnt = Cnt_A[a]
		C[cnt] += 1
	cum_C = []
	cu = 0
	for c in C:
		cu += c
		cum_C.append(cu)
	Ans = []
	for k in range(1, N + 1):
		(ok, ng) = (0, N // k + 1)
		while ok + 1 < ng:
			n = ok + ng >> 1
			if cum_C[n] >= n * k:
				ok = n
			else:
				ng = n
		Ans.append(ok)
	print('\n'.join(map(str, Ans)))
main()


from bisect import *
N = int(input())
A = list(map(int, input().split()))
B = [0] * (N + 1)
for i in range(N):
	B[A[i]] += 1
C = [0] * (N + 1)
for i in range(N + 1):
	C[B[i]] += 1
D = [0]
E = [0]
for i in range(N + 1):
	D.append(D[i] + i * C[i])
	E.append(E[i] + C[-i - 1])
E = E[::-1]
F = []
for i in range(1, N + 1):
	F.append(D[i + 1] // i + E[i + 1])
F = F[::-1]
for i in range(N):
	print(N - bisect_left(F, i + 1))


from collections import defaultdict
from bisect import bisect
N = int(input())
A = list(map(int, input().split()))
d = defaultdict(lambda : 0)
for i in range(N):
	d[A[i]] += 1
C = [0] * (N + 1)
for i in d:
	C[d[i]] += 1
C1 = [0] * (N + 1)
C2 = [0] * (N + 1)
for i in range(N):
	C1[i + 1] = C1[i] + (i + 1) * C[i + 1]
	C2[i + 1] = C2[i] + C[i + 1]
l = [0] * N
for n in range(N):
	l[n] = C1[n + 1] // (n + 1) + C2[N] - C2[n + 1]
	l[n] *= -1
for i in range(N):
	print(bisect(l, -(i + 1)))


import bisect, copy
N = int(input())
A = list(map(int, input().split()))
data = [0 for i in range(0, N + 1)]
for i in range(0, N):
	data[A[i]] += 1
X = []
for i in range(0, N + 1):
	if data[i] != 0:
		X.append(data[i])
X.sort()
n = len(X)
Y = copy.copy(X)
for i in range(1, n):
	Y[i] += Y[i - 1]
ans = {i: 0 for i in range(0, N + 1)}
ans[0] = float('inf')
for i in range(1, N + 1):
	index = bisect.bisect_left(X, i + 1)
	if index != 0:
		t = Y[index - 1] + (n - index) * i
	else:
		t = (n - index) * i
	ans[i] = t // i
pointer = N
i = 1
while N + 1 > i:
	if ans[pointer] >= i:
		print(pointer)
		i += 1
	else:
		pointer -= 1


from collections import Counter
from itertools import groupby

def bin_search(k, greater_count, smaller_sum):
	l = 0
	r = n + 1
	while l < r - 1:
		m = (l + r) // 2
		gc = greater_count[m]
		ss = smaller_sum[m]
		if gc + ss // m >= k:
			l = m
		else:
			r = m
	return l
n = int(input())
aaa = list(map(int, input().split()))
cnt = sorted(Counter(aaa).values())
greater_count = [0] * (n + 2)
smaller_sum = [n] * (n + 2)
remain = greater_count[1] = len(cnt)
total = smaller_sum[1] = 0
pointer = 2
for (c, itr) in groupby(cnt):
	l = len(list(itr))
	remain -= l
	total += c * l
	for i in range(pointer, c + 2):
		greater_count[i] = remain
		smaller_sum[i] = total
	pointer = c + 2
buf = []
for k in range(1, len(cnt) + 1):
	buf.append(bin_search(k, greater_count, smaller_sum))
buf.extend([0] * (n - len(cnt)))
print(*buf)


import bisect
n = int(input())
k = sorted(map(int, input().split()))
hist = []
count = 0
for i in range(n):
	count += 1
	if i == n - 1 or k[i] != k[i + 1]:
		hist.append(count)
		count = 0
hist.sort()
sumh = [0]
for i in range(len(hist)):
	sumh.append(sumh[-1] + hist[i])

def ok(h, d):
	i = bisect.bisect_left(hist, h)
	s = sumh[i] + h * (len(hist) - i)
	return s >= h * d

def binary_search(d):
	(lo, hi) = (0, n // d + 1)
	while hi - lo > 1:
		mid = (lo + hi) // 2
		if ok(mid, d):
			lo = mid
		else:
			hi = mid
	return lo
for d in range(1, n + 1):
	print(binary_search(d))


from bisect import bisect_left

def isOK(c, k, N, L, cum_sum):
	i = bisect_left(L, c)
	s = c * (N - i) + cum_sum[i]
	return s >= c * k
N = int(input())
D = list(map(int, input().split()))
freq = [0] * N
for d in D:
	freq[d - 1] += 1
freq.sort()
cum_sum = [0] * (N + 1)
for i in range(N):
	cum_sum[i + 1] = cum_sum[i] + freq[i]
for k in range(1, N + 1):
	l = 0
	r = int(N / k) + 1
	while l + 1 < r:
		c = int((l + r) / 2)
		ok = isOK(c, k, N, freq, cum_sum)
		if ok:
			l = c
		else:
			r = c
	print(l)


import itertools
import collections
N = int(input())
A = [int(_) for _ in input().split()]
c = sorted(collections.Counter(A).values())
acc = list(itertools.accumulate([0] + c))
n = len(acc) - 1
j = 0
for i in range(1, n + 1):
	r = 0
	while i - j > 0:
		if (i - j) * c[-1 - j] <= acc[-1 - j]:
			r = acc[-1 - j] // (i - j)
			break
		else:
			j += 1
	print(r)
for _ in range(N - n):
	print(0)


from bisect import bisect_left
N = int(input())
A = list(map(int, input().split()))
lst = [0] * (N + 1)
for a in A:
	lst[a - 1] += 1
lst.sort()
s = [0] * (N + 1)
for i in range(N):
	s[i + 1] = s[i] + lst[i + 1]

def check(x, k):
	i = bisect_left(lst, x) - 1
	total = x * (N - i) + s[i]
	return total >= x * k
ans = N
for k in range(1, N + 1):
	while True:
		if check(ans, k):
			break
		ans -= 1
	print(ans)


N = int(input())
A = list(map(int, input().split()))
C = [0] * N
D = [0] * (N + 1)
for a in A:
	C[a - 1] += 1
	D[C[a - 1]] += 1
S = [0] * (N + 1)
for i in range(N):
	S[i + 1] = S[i] + D[i + 1]
ans = N
for K in range(1, N + 1):
	while ans > 0 and S[ans] < K * ans:
		ans -= 1
	print(ans)


from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(2147483647)
INF = 10 ** 20

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def I():
	return int(sys.stdin.buffer.readline())

def LS():
	return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

def S():
	return sys.stdin.buffer.readline().rstrip().decode('utf-8')

def IR(n):
	return [I() for i in range(n)]

def LIR(n):
	return [LI() for i in range(n)]

def SR(n):
	return [S() for i in range(n)]

def LSR(n):
	return [LS() for i in range(n)]

def SRL(n):
	return [list(S()) for i in range(n)]

def MSRL(n):
	return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

def bi_search(k):
	ok = 0
	ng = n // k + 1
	while ng > ok + 1:
		mid = (ng + ok) // 2
		if calc(mid, k):
			ok = mid
		else:
			ng = mid
	return ok

def calc(x, k):
	l = bisect_left(L, (x, 0))
	if kv_acc[l - 1] + acc[l] * x >= k * x:
		return True
	else:
		return False
n = I()
A = LI()
L = [(0, 0)] + sorted([(k, v) for (k, v) in Counter(Counter(A).values()).items()])
m = len(L)
acc = [0] * (m + 1)
for i in range(m - 1, -1, -1):
	acc[i] = acc[i + 1] + L[i][1]
kv_acc = list(accumulate([k * v for (k, v) in L]))
for k in range(1, n + 1):
	print(bi_search(k))


import bisect
from collections import Counter
import sys
input = sys.stdin.buffer.readline
N = int(input())
a = list(map(int, input().split()))
c = sorted(list(Counter(a).values()))
M = len(c)
cs = [0] * (M + 1)
for i in range(M):
	cs[i + 1] = cs[i] + c[i]
kmax = [0] * (N + 1)
for i in range(1, N + 1):
	j = bisect.bisect_left(c, i) if i <= c[-1] else M
	kmax[i] = (cs[j] + i * (M - j)) // i
idx = N
for k in range(1, N + 1):
	while k > kmax[idx]:
		if idx == 0:
			break
		idx -= 1
	print(idx)


N = int(input())
A = list(map(int, input().split()))
types = {}
for i in A:
	types[i] = types.get(i, 0) + 1
A = sorted([types[k] for k in types], reverse=True)
L = len(A)
cumsum = [0 for i in range(L + 1)]
for i in range(L - 1, -1, -1):
	cumsum[i] = A[i] + cumsum[i + 1]

def getMidPoint(lo, hi, O):
	if lo >= hi:
		return lo
	mid = lo + (hi - lo + 1) // 2
	if A[mid] > O:
		return getMidPoint(mid, hi, O)
	else:
		return getMidPoint(lo, mid - 1, O)
getMid = [getMidPoint(0, L - 1, o) for o in range(N + 1)]

def calc(O):
	mid = getMid[O]
	if A[mid] < O:
		mid = -1
	return mid + 1 + cumsum[mid + 1] // O
for K in range(1, N + 1):

	def getO(lo, hi):
		if lo >= hi:
			return lo
		mid = lo + (hi - lo + 1) // 2
		if calc(mid) < K:
			return getO(lo, mid - 1)
		else:
			return getO(mid, hi)
	print(getO(0, N))


import os
import sys
if os.getenv('LOCAL'):
	sys.stdin = open('_in.txt', 'r')
sys.setrecursionlimit(2147483647)
INF = float('inf')
IINF = 10 ** 18
MOD = 10 ** 9 + 7
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

def test(k):
	bc = np.bincount(A)
	bc.sort()
	bc = bc[np.searchsorted(bc, 1):]
	bc = bc[::-1]
	ret = 0
	while len(bc) >= k:
		bc[:k] -= 1
		bc.sort()
		bc = bc[np.searchsorted(bc, 1):]
		bc = bc[::-1]
		ret += 1
	return ret

def cumsum(it):
	s = 0
	ret = []
	for a in it:
		s += a
		ret.append(s)
	return ret
C = [0] * (N + 1)
for a in A:
	C[a] += 1
C.sort()
cs = list(reversed(cumsum(reversed(C))))

def solve(k):
	cnt = N // k
	if C[-1] <= cnt:
		return cnt
	ng = 0
	ok = k
	while abs(ng - ok) > 1:
		i = (ng + ok) // 2
		s = N - cs[-i]
		cnt = s // (k - i)
		max_c = C[-i - 1]
		if max_c <= cnt:
			ok = i
		else:
			ng = i
	if ok < k:
		i = ok
		s = N - cs[-i]
		return s // (k - i)
	else:
		return 0
ans = [0] * N
for k in reversed(range(1, N + 1)):
	ans[k - 1] = solve(k)
print(*ans, sep='\n')


import sys
from collections import Counter
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
	n = int(input())
	aa = list(map(int, input().split()))
	aa = list(Counter(aa).values())
	aa.sort()
	cs = [0]
	s = 0
	for a in aa:
		s += a
		cs += [s]
	ans = n + 1
	i = len(aa)
	for k in range(1, n + 1):
		while 1:
			while i > 0 and aa[i - 1] >= ans:
				i -= 1
			s = cs[i] + ans * (len(aa) - i)
			if s >= ans * k:
				break
			else:
				ans -= 1
		print(ans)
main()


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
d = Counter(c.values())
dx = [0 for _ in range(n + 1)]
for i in range(1, n + 1):
	dx[i] = dx[i - 1] + i * d[i]
xdx = [0 for _ in range(n + 2)]
xdx[n] = d[n]
for i in range(n - 1, 0, -1):
	xdx[i] = xdx[i + 1] + d[i]
res = [0] + [(dx[i] + i * xdx[i + 1]) // i for i in range(1, n + 1)]
ans = [0 for _ in range(n)]
cur = n
for i in range(n):
	while cur > 0 and res[cur] < i + 1:
		cur -= 1
	if cur > 0:
		ans[i] = cur
print(*ans, sep='\n')


N = int(input())
A = list(map(int, input().split()))
dic = {}
for a in A:
	if a not in dic:
		dic[a] = 1
	else:
		dic[a] += 1
B = []
for i in dic:
	B.append(dic[i])
B.sort()
B_sub = B.copy()
for i in range(len(B) - 1):
	B_sub[i + 1] += B_sub[i]
aind = N + 1
nind = len(B) - 1
for i in range(N):
	i += 1
	while True:
		while nind > 0 and B[nind] > aind - 1:
			nind -= 1
		if i > len(B):
			print(0)
			break
		elif (len(B) - 1 - nind) * (aind - 1) + B_sub[nind] >= (aind - 1) * i:
			print(aind - 1)
			break
		aind -= 1


def main():
	from sys import stdin
	input = stdin.readline
	from collections import Counter as ct
	from bisect import bisect_left as bl
	n = int(input())
	max_a = sorted(ct(list(map(int, input().split()))).values())
	now_a = [i for i in max_a]
	m = len(max_a)
	cnt = m
	ans = 0
	ans_list = [0] * (n - m)
	for use in range(m, 1, -1):
		rest = ans
		nex = now_a[0]
		while rest:
			val = nex
			start = bl(now_a, val + 1)
			nex += 1
			q = max(-1, start - 1 - rest, bl(max_a, now_a[start - 1] + 1) - 1)
			for i in range(start - 1, q, -1):
				now_a[i] += 1
			if now_a[start - 1] == 1:
				cnt += start - 1 - q
			rest -= start - 1 - q
			if start != m:
				nex = now_a[start]
		while cnt >= use:
			ans += 1
			rest = use
			nex = now_a[-1]
			end = m
			while rest:
				val = nex
				start = bl(now_a, val)
				if start != 0:
					nex = now_a[start - 1]
				end = min(end, bl(now_a, val + 1), start + rest)
				for i in range(start, end):
					now_a[i] -= 1
				if now_a[start] == 0:
					cnt -= end - start
				rest -= end - start
				end = start
		ans_list.append(ans)
	print(n)
	for i in ans_list[::-1]:
		print(i)
main()


from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
C = [0] * (N + 1)
S = [0] * (N + 1)
for a in Counter(A).values():
	C[a] += 1
	S[a] += a
for i in range(1, N + 1):
	C[i] += C[i - 1]
	S[i] += S[i - 1]
for K in range(1, N + 1):
	(ok, ng) = (0, N + 1)
	while ng - ok > 1:
		mid = (ng + ok) // 2
		if S[mid] + mid * (C[-1] - C[mid]) >= K * mid:
			ok = mid
		else:
			ng = mid
	print(ok)


import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
cnt = [0] * (N + 1)
B = [0] * (N + 1)
for Ai in A:
	cnt[Ai] += 1
	B[cnt[Ai]] += 1
acc = [0]
for Bi in B:
	acc.append(acc[-1] + Bi)
x = N
for K in range(1, N + 1):
	while x > 0 and K * x > acc[x + 1]:
		x -= 1
	print(x)


from collections import Counter
import bisect

def main():
	N = int(input())
	A = list(map(int, input().split()))
	count_list = list(Counter(A).values())
	count_list.sort()
	cumsum_count = [0] * len(count_list)
	cumsum_count[0] = count_list[0]
	for i in range(1, len(count_list)):
		cumsum_count[i] = cumsum_count[i - 1] + count_list[i]
	ans_list = [0] * N
	n_max = N
	for k in range(1, len(count_list) + 1):
		n_max = min(n_max, N // k)
		s = 0
		while True:
			index = bisect.bisect_left(count_list, n_max)
			s = n_max * (len(count_list) - index)
			if index > 0:
				s += cumsum_count[index - 1]
			if s >= k * n_max or n_max == 0:
				break
			n_max -= 1
		ans_list[k - 1] = n_max
	for ans in ans_list:
		print(ans)

def __starting_point():
	main()
__starting_point()


N = int(input())
A = list(map(int, input().split()))
num = [0 for _ in range(N)]
for a in A:
	num[a - 1] += 1
num.sort()
cum = [0 for _ in range(N)]
cum[0] = num[0]
for i in range(1, N):
	cum[i] = cum[i - 1] + num[i]
index = N - 1
ans = N
for k in range(1, N + 1):
	while ans > 0:
		tmp_index = index
		while tmp_index >= 0 and num[tmp_index] > ans:
			tmp_index -= 1
		decided = N - tmp_index - 1
		rest_total = 0 if tmp_index < 0 else cum[tmp_index]
		if rest_total >= ans * (k - decided):
			index = tmp_index
			break
		ans -= 1
	print(ans)


import sys
stdin = sys.stdin
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
nn = lambda : list(stdin.readline().split())
ns = lambda : stdin.readline().rstrip()
import bisect
from collections import Counter
n = ni()
a = na()
c = sorted(Counter(a).values())
cc = [0]
m = len(c)
for i in c:
	cc.append(cc[-1] + i)

def is_ok(k, arg):
	b = bisect.bisect_right(c, arg)
	p = cc[b] + (m - b) * arg
	return True if p >= arg * k else False
for k in range(1, n + 1):
	if k > m:
		print(0)
		continue
	(ok, ng) = (-1, n // k + 1)
	while abs(ok - ng) > 1:
		mid = (ok + ng) // 2
		if is_ok(k, mid):
			ok = mid
		else:
			ng = mid
	print(ok)


def f(m, k):
	if m == 0:
		return 0
	if m < k:
		return 0
	z = 0
	if acc[m] // k >= c[m]:
		return acc[m] // k
	else:
		return f(m - 1, k - 1)
import sys
readline = sys.stdin.readline
from itertools import accumulate
n = int(input())
a = [int(i) for i in readline().split()]
res = [0] * (n + 1)
for i in a:
	res[i] += 1
c = [0]
for i in res:
	if i > 0:
		c.append(i)
c.sort()
l = len(c) - 1
acc = list(accumulate(c))
res = [n] + [acc[m] // c[m] for m in range(1, l + 1)]
m = l
for k in range(1, n + 1):
	k -= l - m
	if res[m] >= k:
		print(acc[m] // k)
	else:
		while res[m] < k:
			m -= 1
			k -= 1
		print(acc[m] // k)


import sys
from collections import Counter
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
c = Counter()
for x in a:
	c[x] += 1
cv = Counter()
for v in c.values():
	cv[v] += 1

def check(x, K):
	t = 0
	for (k, v) in cv.items():
		t += min(k, x) * v
	return t >= K * x
res = [N] * (N + 1)
for K in range(1, N):
	ok = 0
	ng = res[K] + 1
	while ng - ok > 1:
		m = (ok + ng) // 2
		if check(m, K + 1):
			ok = m
		else:
			ng = m
	res[K + 1] = ok
for r in res[1:]:
	print(r)


I = int(input())
from collections import Counter
from itertools import accumulate
As = map(int, input().split())
xs = sorted([x for x in Counter(As).values()]) + [10 ** 18]
Xs = accumulate(xs)
N = len(xs) - 1
rs = [0] * I
mny = N + 1
for (l, (x, X)) in enumerate(zip(xs[1:], Xs)):
	l += 2
	y = X // (x + 1) + (N - l + 1) + 1
	for i in range(y, mny):
		rs[i - 1] = X // (i - (N - l + 1))
	mny = min(y, mny)
for r in rs:
	print(r)


from collections import Counter as C
N = int(input())
A = sorted(list(C([int(a) for a in input().split()]).values()))
X = [0] * 303030
for a in A:
	X[a] += 1
s = 0
c = 0
B = [0] * 303030
for i in range(300030)[::-1]:
	s += c
	B[i] += s
	c += X[i]

def chk(k, a):
	if N - B[a] >= k * a:
		return 1
	return 0
for i in range(1, N + 1):
	(l, r) = (0, N + 1)
	while r - l > 1:
		m = (l + r) // 2
		if chk(i, m):
			l = m
		else:
			r = m
	print(l)


import sys
input = sys.stdin.readline
from collections import Counter
from itertools import accumulate
from math import floor
from bisect import bisect_left

def main():
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter(a)
	c = list(c.values())
	d = Counter(c)
	d_li = [0] * (n + 1)
	for (k, v) in list(d.items()):
		d_li[k] = v
	dk_acm = list(accumulate(d_li))
	kdk_acm = [0]
	for (k, e) in enumerate(d_li[1:], 1):
		kdk_acm.append(kdk_acm[-1] + k * e)

	def f(x):
		kdk_sm = kdk_acm[x]
		dk_sm = dk_acm[n] - dk_acm[x]
		return floor((kdk_sm + x * dk_sm) / x)
	fs = [float('inf')] + [f(x) for x in range(1, n + 1)]
	fs = fs[::-1]
	for k in range(1, n + 1):
		print(n - bisect_left(fs, k))

def __starting_point():
	main()
__starting_point()


from collections import Counter
from itertools import accumulate
import bisect
printRows = lambda x: print('\n'.join(map(str, x)))
n = int(input())
a = list(map(int, input().split()))
b = sorted(Counter(a).values())
exist = len(b)
b = [0] * (n - exist) + b
c = list(accumulate([0] + b))
ans = [n]
for k in range(2, n // 2 + 1):
	if k > exist:
		ans.append(0)
		continue
	l = 0
	r = n // k + 1
	while r - l > 1:
		x = (r + l) // 2
		i = bisect.bisect_left(b, x)
		if c[i] + (n - i) * x >= x * k:
			l = x
		else:
			r = x
	ans.append(l)
for k in range(max(n // 2 + 1, 2), n + 1):
	if exist >= k:
		ans.append(1)
	else:
		ans.append(0)
printRows(ans)


N = int(input())
A = list(map(int, input().split()))
C = [0] * (N + 1)
for a in A:
	C[a] += 1
D = [0] * (N + 1)
for c in C:
	D[c] += 1
P = [0] * (N + 1)
Q = [0] * (N + 1)
for i in range(1, N + 1):
	P[i] = P[i - 1] + i * D[i]
	Q[i] = Q[i - 1] + D[i]
F = [0] * (N + 1)
for i in range(1, N + 1):
	F[i] = int((P[i] + i * (Q[N] - Q[i])) / i)
index = N
for i in range(1, N + 1):
	while True:
		if index == 0:
			print(0)
			break
		if F[index] >= i:
			print(index)
			break
		else:
			index -= 1


import sys
from collections import Counter
readline = sys.stdin.readline
N = int(readline())
A = list(map(int, readline().split()))
table = Counter()
for a in A:
	table[a] += 1
table = list(table.values())
table.sort(reverse=True)
L = len(table)
ata = table[:] + [0]
for i in range(1, L):
	ata[i] += ata[i - 1]
vm = [-1] * (N + 2)
for med in range(N, 0, -1):
	idx = -1
	for v in range(max(0, vm[med + 1]), L):
		if table[v] <= med:
			break
		idx = v
	vm[med] = idx
Ans = [None] * N
for k in range(1, N + 1):
	ok = 0
	ng = N // k + 1
	while abs(ok - ng) > 1:
		med = (ok + ng) // 2
		res = N - ata[vm[med]] + med * (vm[med] + 1)
		if res >= k * med:
			ok = med
		else:
			ng = med
	Ans[k - 1] = ok
print('\n'.join(map(str, Ans)))


n = int(input())
arr = list(map(int, input().split()))
from collections import Counter
c = Counter(arr)
c = list(c.values())
c.sort()
s = n
sol = []
removed = 0
for k in range(1, n + 1):
	rest = k - removed
	while c and c[-1] > s // rest:
		s -= c[-1]
		c.pop()
		rest -= 1
		removed += 1
	sol.append(s // rest)
print('\n'.join(map(str, sol)))


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import Counter
(N, *A) = map(int, read().split())
counter = Counter(A)
C = list(counter.values())
C.sort()
S = sum(C)
answer = []
removed = 0
for K in range(1, N + 1):
	rest = K - removed
	while C and C[-1] > S // rest:
		S -= C[-1]
		C.pop()
		removed += 1
		rest -= 1
	answer.append(S // rest)
print('\n'.join(map(str, answer)))


from bisect import bisect_left
N = int(input())
A = list(map(int, input().split()))
lst = [0] * (N + 1)
for a in A:
	lst[a - 1] += 1
lst.sort()
s = [0] * (N + 1)
for i in range(N):
	s[i + 1] = s[i] + lst[i + 1]

def check(x, k):
	i = bisect_left(lst, x) - 1
	total = x * (N - i) + s[i]
	return total >= x * k
for k in range(1, N + 1):
	l = 0
	r = N // k + 1
	while l + 1 < r:
		c = (l + r) // 2
		if check(c, k):
			l = c
		else:
			r = c
	print(l)


from collections import Counter
from itertools import accumulate
from bisect import bisect_right
N = int(input())
As = list(map(int, input().split()))
ct = Counter(As)
ctm = [c[1] for c in ct.most_common()]
ctm.reverse()
L = len(ctm)
acc = [0] + list(accumulate(ctm))
arr = [0]
for n in range(1, N + 1):
	idx = bisect_right(ctm, n)
	arr.append(acc[idx] + n * (L - idx))
for n in range(1, N + 1):
	f = 0
	t = N // n + 1
	while f + 1 < t:
		m = f + (t - f) // 2
		if arr[m] >= m * n:
			f = m
		else:
			t = m
	print(f)


n = int(input())
A = list(map(int, input().split()))
B = [0] * (n + 1)
C = [0] * (n + 1)
for a in A:
	B[a] += 1
	C[B[a]] += 1
X = [0]
for i in range(1, n + 1):
	X.append(X[i - 1] + C[i])
for j in range(1, n + 1):
	X[j] = X[j] // j
ind = n
k = 1
while k <= n:
	if ind < 0:
		for _ in range(n - k + 1):
			print(0)
		break
	if k <= X[ind]:
		print(ind)
		k += 1
	else:
		ind -= 1


import sys
input = sys.stdin.readline

def I():
	return int(input())

def MI():
	return map(int, input().split())

def LI():
	return list(map(int, input().split()))

def main():
	import bisect
	N = I()
	A = LI()
	from collections import defaultdict
	dd = defaultdict(int)
	for i in range(N):
		dd[A[i]] += 1
	L = []
	for (k, v) in dd.items():
		L.append(v)
	L.sort()
	nl = len(L)
	S = [0] * (nl + 1)
	for i in range(nl):
		S[i + 1] = S[i] + L[i]
	ans = [0] * (N + 1)
	for m in range(1, N + 1):
		temp = 0
		num = bisect.bisect_left(L, m)
		temp += S[num]
		temp += (nl - num) * m
		maxk = temp // m
		ans[maxk] = max(ans[maxk], m)
	M = 0
	for i in range(N, -1, -1):
		M = max(M, ans[i])
		ans[i] = M
	for i in range(1, N + 1):
		print(ans[i])
main()


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10 ** 9 + 7
inf = float('inf')

def I():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))
n = I()
a = LI()
cnt = list(Counter(a).values())
d = [0] * (n + 1)
for i in cnt:
	d[i] += 1
d = list(accumulate(d))
m = d[-1]
S = [0] * (n + 1)
for i in range(1, n + 1):
	S[i] = S[i - 1] + (m - d[i - 1])
S2 = [0] * (n + 1)
for i in range(1, n + 1):
	S2[i] = S[i] // i
tmp = n
for k in range(1, n + 1):
	while S2[tmp] < k:
		tmp -= 1
		if tmp <= 0:
			print(0)
			break
	else:
		print(tmp)


import bisect
N = int(input())
count = {}
for x in map(int, input().split()):
	count[x] = count.get(x, 0) + 1
a = sorted(count.values())
sums = a[:]
n = len(a)
for i in range(1, n):
	sums[i] += sums[i - 1]

def check(k, x):
	pos = bisect.bisect_right(a, x)
	if pos == 0:
		return x * n >= k * x
	return sums[pos - 1] + x * (n - pos) >= k * x
x = N
for k in range(1, N + 1):
	while not check(k, x):
		x -= 1
	print(x)


from collections import Counter
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
B = list(Counter(A).values())
C = [0] * N
for i in B:
	C[i - 1] += 1
F = list(accumulate(C))
S = [0] * N
f = [0] * N
S[0] = f[0] = sum(C)
for i in range(2, N + 1):
	S[i - 1] = S[i - 2] + C[i - 1] + S[0] - F[i - 1]
	f[i - 1] = S[i - 1] / i
f.sort()
n = 0
K = 1
while K != N + 1:
	if K <= f[n]:
		print(N - n)
		K += 1
	else:
		n += 1
	if n == N:
		for i in range(N - K + 1):
			print(0)
		K = N + 1


from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = list(Counter(A).values())
D = [0] * (N + 1)
for (k, d) in Counter(C).items():
	D[k] = d
(ckd, cd) = ([0] * (N + 1), [0] * (N + 1))
for i in range(1, N + 1):
	cd[i] = cd[i - 1] + D[i]
	ckd[i] = ckd[i - 1] + i * D[i]
INF = float('inf')

def f(x):
	if x:
		return (x * (cd[-1] - cd[x]) + ckd[x]) // x
	return INF
cur = N
v = f(cur)
for k in range(1, N + 1):
	while k > v:
		cur -= 1
		v = f(cur)
	print(cur)


import collections
import numpy as np
n = int(input())
a = list(map(int, input().split()))
counter = collections.Counter(a)
nums = list(counter.values())
num_counter = collections.Counter(nums)
lastest_add = np.count_nonzero(nums)
(building, longests) = ([0], [0])
for i in range(1, n + 1):
	appended = building[-1] + lastest_add
	building.append(appended)
	longests.append(appended // i)
	lastest_add -= num_counter[i]
lastest_longest = 0
k_most = []
for (i, x) in enumerate(reversed(longests)):
	while x > lastest_longest:
		lastest_longest += 1
		k_most.append(n - i)
k_most.extend([0] * (n - len(k_most)))
for longests_num in k_most:
	print(longests_num)


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10 ** 9 + 7
inf = float('inf')

def I():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))
n = I()
a = LI()
cnt = list(Counter(a).values())
cnt.sort()
m = len(cnt)
S = [0] * (n + 1)
for x in range(1, n + 1):
	l = bl(cnt, x)
	S[x] = S[x - 1] + (m - l)
for k in range(1, n + 1):
	(high, low) = (n + 1, 0)
	while high - low > 1:
		mid = (high + low) // 2
		if S[mid] >= k * mid:
			low = mid
		else:
			high = mid
	print(low)


from collections import Counter
from itertools import accumulate
import bisect
n = int(input())
a = list(map(int, input().split()))
b = sorted(Counter(a).values())
exist = len(b)
b = [0] * (n - exist) + b
c = list(accumulate([0] + b))
print(n)
for k in range(2, n // 2 + 1):
	l = 0
	r = n + 1
	while r - l > 1:
		x = (r + l) // 2
		i = bisect.bisect_left(b, x)
		if c[i] + (n - i) * x >= x * k:
			l = x
		else:
			r = x
	print(l)
for k in range(max(n // 2 + 1, 2), n + 1):
	if exist >= k:
		print(1)
	else:
		print(0)


def f_distinct_numbers():
	from collections import Counter
	N = int(input())
	A = [int(i) for i in input().split()]
	c = [0] * (N + 1)
	d = [0] * (N + 1)
	for a in A:
		c[a] += 1
		d[c[a]] += 1
	cumsum = [0] * (N + 1)
	judge = [0] * (N + 1)
	for i in range(1, N + 1):
		cumsum[i] = cumsum[i - 1] + d[i]
		judge[i] = cumsum[i] // i
	ans = []
	x = N
	for k in range(1, N + 1):
		while x > 0 and k > judge[x]:
			x -= 1
		ans.append(x)
	return ' '.join(map(str, ans))
print(f_distinct_numbers())


import sys
from collections import Counter
from bisect import bisect_left
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

class BitSum:

	def __init__(self, n):
		self.n = n
		self.table = [0] * (n + 1)

	def update(self, i, x):
		i += 1
		while i <= self.n:
			self.table[i] += x
			i += i & -i

	def sum(self, i):
		i += 1
		res = 0
		while i > 0:
			res += self.table[i]
			i -= i & -i
		return res

def main():
	n = int(input())
	aa = list(map(int, input().split()))
	aa = list(Counter(aa).values())
	aa.sort()
	bit = BitSum(len(aa))
	for (i, a) in enumerate(aa):
		bit.update(i, a)
	for k in range(1, n + 1):
		l = 0
		r = n // k + 2
		while l + 1 < r:
			m = (l + r) // 2
			i = bisect_left(aa, m)
			s = bit.sum(i - 1) + m * (len(aa) - i)
			if s >= m * k:
				l = m
			else:
				r = m
		print(l)
main()


import sys
import collections as cl
N = int(input())
A = list(map(int, sys.stdin.readline().split()))
c = cl.Counter(A)
NumberTupleList = c.most_common()
NumberList = [x[1] for x in NumberTupleList[::-1]]
LengthOfNumberList = len(NumberList)
FormulaList = [0 for i in range(N)]
flag = 0
S = sum(NumberList)
for x in range(1, N + 1):
	while flag < LengthOfNumberList and NumberList[flag] <= x:
		flag += 1
	if flag < LengthOfNumberList:
		FormulaList[x - 1] = (sum(NumberList[:flag]) + x * (LengthOfNumberList - flag)) / x
	else:
		FormulaList[x - 1] = S / x
pin = N - 1
for K in range(1, N + 1):
	while pin >= 0 and K > FormulaList[pin]:
		pin -= 1
	print(pin + 1)


from collections import Counter
from itertools import accumulate
n = int(input())
A = tuple(map(int, input().split()))
C = Counter(A)
D = [0] * (n + 1)
for v in C.values():
	D[v] += 1
E = tuple(accumulate((k * d for (k, d) in enumerate(D))))
D = tuple(accumulate(D))
F = [0] * (n + 1)
for x in range(1, n + 1):
	temp = (E[x] + x * (D[n] - D[x])) // x
	F[x] = temp
for k in range(1, n + 1):
	ok = 0
	ng = n + 1
	while ng - ok > 1:
		mid = (ok + ng) // 2
		if k <= F[mid]:
			ok = mid
		else:
			ng = mid
	print(ok)


from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
mod = 10 ** 9 + 7
eps = 10 ** (-7)

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def inpl_str():
	return list(sys.stdin.readline().split())
N = inp()
AA = inpl()
cnts = defaultdict(int)
ed = set()
for a in AA:
	cnts[a] += 1
	ed.add(a)
aa1 = [[i, 0] for i in range(1, N + 1)]
for e in ed:
	aa1[cnts[e] - 1][1] += 1
aa2 = [0]
aa3 = [0]
for (t, n) in aa1:
	aa2.append(aa2[-1] + n)
	aa3.append(aa3[-1] + n * t)
L = len(aa1)
tmpl_t = []
tmpl_c = []
for (i, (t, n)) in enumerate(aa1):
	tmp = n + aa3[i] // t
	tmp += aa2[-1] - aa2[i + 1]
	tmpl_t.append(t)
	tmpl_c.append(tmp)
tmpl_t.reverse()
tmpl_t.append(0)
tmpl_c.reverse()
ans = [0] * N
for i in range(1, N + 1):
	idx = bisect.bisect_left(tmpl_c, i)
	if idx == 0:
		ans[i - 1] = N // i
	else:
		ans[i - 1] = tmpl_t[idx]
print('\n'.join(map(str, ans)))


from bisect import bisect
n = int(input())
a = list(map(int, input().split()))
a.sort()
k = a[0]
data = []
count = 1
for i in range(1, n):
	if a[i] == k:
		count += 1
	else:
		k = a[i]
		data.append(count)
		count = 1
data.append(count)
data.sort()
l = len(data)
lst = []
for u in data:
	if lst:
		lst.append(u + lst[-1])
	else:
		lst.append(u)
li = [0] * (n + 1)
for ans in range(1, n + 1):
	i = bisect(data, ans)
	if i == 0:
		j = ans * l
	else:
		j = lst[i - 1] + ans * (l - i)
	k = j // ans
	li[k] = ans
z = 0
for i in range(n):
	if li[n - i] == 0:
		li[n - i] = z
	else:
		z = li[n - i]
for i in range(1, n + 1):
	print(li[i])


import bisect
import sys
input = sys.stdin.readline
n = int(input())
a = [int(item) for item in input().split()]
cnt = [0] * (n + 1)
for item in a:
	cnt[item] += 1
cnt.sort()
cumsum = [0] * (n + 2)
for i in range(n + 1):
	cumsum[i + 1] = cumsum[i] + cnt[i]
indexes = [0] * (n + 1)
for i in range(n + 1):
	indexes[i] = bisect.bisect_left(cnt, i) - 1
ans = []
for i in range(n):
	if cnt[i + 1] == 0:
		ans.append(0)
		continue
	l = 0
	r = n + 1
	while r - l > 1:
		mid = (l + r) // 2
		index = indexes[mid]
		if index <= i:
			l = mid
			continue
		num = index - i
		if mid * num <= cumsum[index + 1]:
			l = mid
		else:
			r = mid
	ans.append(l)
ans.reverse()
print('\n'.join([str(item) for item in ans]))


import sys
sys.setrecursionlimit(2147483647)
INF = float('inf')
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().rstrip()

def bisection(l, r, f, discrete=True, left=True):
	eps = 1 if discrete else 10 ** (-12)
	if (not left) ^ f(r):
		return r if left else r + 1
	elif left ^ f(l):
		return l - 1 if left else l
	while r - l > eps:
		h = (l + r) // 2 if discrete else (l + r) / 2
		if (not left) ^ f(h):
			l = h
		else:
			r = h
	return h if not discrete else l if left else r

def resolve():
	from collections import Counter
	from bisect import bisect_left
	n = int(input())
	A = Counter(map(int, input().split()))
	A = list(A.values())
	A.sort()
	m = len(A)
	S = [0] * (m + 1)
	for i in range(m):
		S[i + 1] = S[i] + A[i]
	for k in range(1, n + 1):

		def check(p):
			i = bisect_left(A, p)
			return S[i] + (m - i) * p >= k * p
		print(bisection(0, n // k + 1, check))
resolve()


import sys
input = sys.stdin.readline
import bisect
from collections import Counter

def solve():
	n = int(input())
	a = sorted(list((int(i) for i in input().split())))
	c = Counter(a)
	val = list(c.values())
	val.sort()
	ans = [0] * (n + 1)
	t = len(val)
	for i in range(1, n + 1):
		place = bisect.bisect_left(val, i)
		ans[i] = ans[i - 1] + t - place
	for i in range(1, n + 1):
		ok = 0
		ng = n + 1
		while ng - ok > 1:
			mid = (ok + ng) // 2
			if ans[mid] >= i * mid:
				ok = mid
			else:
				ng = mid
		print(ok)
solve()


from collections import defaultdict
from bisect import bisect_right
import sys
sys.setrecursionlimit(10 ** 9)
input = lambda : sys.stdin.readline().rstrip()
inpl = lambda : list(map(int, input().split()))

class CountUp:

	def __init__(self, start=0):
		self.index = start - 1

	def __call__(self):
		self.index += 1
		return self.index
N = int(input())
A = inpl()
ui = defaultdict(CountUp())
B = []
Ns = 0
for a in A:
	i = ui[a]
	if i >= Ns:
		Ns += 1
		B.append(1)
	else:
		B[i] += 1
B.sort()
C = []
prev = B[0]
n = 0
for b in B:
	if b == prev:
		n += 1
	else:
		C.append((prev, n))
		prev = b
		n = 1
else:
	C.append((prev, n))
f = []
S = 0
T = Ns
nc = 0
nxtc = C[0][0]
for i in range(1, N + 1):
	if i == nxtc:
		n = C[nc][1]
		S += i * n
		T -= n
		nc += 1
		if nc < len(C):
			nxtc = C[nc][0]
		else:
			nxtc = None
	f.append(-(S // i + T))
for K in range(1, N + 1):
	print(bisect_right(f, -K))


import sys
input = sys.stdin.readline
n = int(input())
a = [int(j) for j in input().split()]
from collections import Counter
c = Counter(a)
l = c.most_common()
ll = []
for (i, j) in l:
	ll.append(j)
ll.sort()
s = sum(ll)
rem = 0
for k in range(1, n + 1):
	rest = k - rem
	while ll and ll[-1] > s // rest:
		s -= ll[-1]
		ll.pop()
		rem += 1
		rest -= 1
	print(s // rest)


import bisect
n = int(input())
A = list(map(int, input().split()))
counts = [0] * n
for a in A:
	counts[a - 1] += 1
counts.sort()
cumsum = []
num = 0
for count in counts:
	num += count
	cumsum.append(num)
answers = [0] * n
for i in range(1, n + 1):
	idx = bisect.bisect_right(counts, i)
	left = cumsum[idx - 1]
	right = (n - idx) * i
	K = (right + left) // i
	answers[K - 1] = i
now = 0
for i in range(n - 1, -1, -1):
	if answers[i] == 0:
		answers[i] = now
	now = answers[i]
for ans in answers:
	print(ans)


from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl = lambda : list(map(int, input().split()))
inm = lambda : map(int, input().split())
DBG = True
BIG = 999999999
R = 10 ** 9 + 7

def ddprint(x):
	if DBG:
		print(x)

def f(k, p):
	return c[p] >= k * p

def ff(k, p):
	acc = n
	for i in range(len(b)):
		if b[i] > p:
			acc -= b[i] - p
		else:
			break
	return acc >= k * p
n = inn()
a = inl()
h = {}
for x in a:
	if x in h:
		h[x] += 1
	else:
		h[x] = 1
b = []
for x in h:
	b.append(h[x])
b.sort(reverse=True)
c = [0] * (n + 1)
for p in range(1, n + 1):
	acc = n
	for i in range(len(b)):
		if b[i] > p:
			acc -= b[i] - p
		else:
			break
	c[p] = acc
for k in range(1, n + 1):
	mn = 0
	mx = n // k + 1
	while mx > mn + 1:
		mid = (mn + mx) // 2
		if f(k, mid):
			mn = mid
		else:
			mx = mid
	print(mn)


def main():
	from collections import Counter as ct
	from bisect import bisect_left as bl
	n = int(input())
	max_a = sorted(ct(list(map(int, input().split()))).values())
	now_a = [i for i in max_a]
	m = len(max_a)
	cnt = m
	ans = 0
	ans_list = []
	for use in range(n, 0, -1):
		rest = ans
		nex = now_a[0]
		while rest:
			val = nex
			start = bl(now_a, val + 1)
			nex += 1
			for i in range(start - 1, -1, -1):
				if now_a[i] == max_a[i]:
					if start != m:
						nex = now_a[start]
					break
				elif now_a[i] == 0:
					cnt += 1
				now_a[i] += 1
				rest -= 1
				if rest == 0:
					break
		while True:
			if cnt < use:
				ans_list.append(ans)
				break
			ans += 1
			rest = use
			nex = now_a[-1]
			end = m
			while rest:
				val = nex
				start = bl(now_a, val)
				if start != 0:
					nex = now_a[start - 1]
				for i in range(start, end):
					if now_a[i] > val:
						break
					elif now_a[i] == 1:
						cnt -= 1
					now_a[i] -= 1
					rest -= 1
					if rest == 0:
						break
				end = start
	for i in ans_list[::-1]:
		print(i)
main()


from collections import Counter
from itertools import groupby, accumulate
n = int(input())
aaa = list(map(int, input().split()))
cnt = sorted(Counter(aaa).values())
remain = len(cnt)
total = 0
kkk = [0] * (n + 1)
p = 1
for (c, itr) in groupby(cnt):
	l = len(list(itr))
	for i in range(p, c + 1):
		kkk[remain + total // i] = i
	remain -= l
	total += c * l
	p = c + 1
for i in range(p, n + 1):
	kkk[remain + total // i] = i
kkk.reverse()
kkk = list(accumulate(kkk, func=max))
kkk.reverse()
print(*kkk[1:])


from collections import Counter
from bisect import bisect_left
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
a = list(Counter(A).values())
a.sort()
b = list(accumulate(a + [0]))
s = sum(a)
length = len(a)
for i in range(1, N + 1):
	if i == 1:
		print(s)
	elif len(a) < i:
		print(0)
	else:
		n = s // i
		for j in reversed(range(1, n + 1)):
			t = bisect_left(a, j)
			if j * i <= b[t - 1] + (length - t) * j:
				print(j)
				break


import bisect
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = []
cnt = 1
for i in range(1, n):
	if a[i] == a[i - 1]:
		cnt += 1
	else:
		b.append(cnt)
		cnt = 1
b.append(cnt)
b.sort()
p = [0] * (n + 1)
for i in range(1, n + 1):
	kp = bisect.bisect_left(b, i)
	p[i] = p[i - 1] + len(b) - kp
for k in range(1, n + 1):
	ok = 0
	ng = n + 1
	while abs(ng - ok) > 1:
		mid = (ok + ng) // 2
		if p[mid] >= k * mid:
			ok = mid
		else:
			ng = mid
	print(ok)


from itertools import accumulate
(N, *A) = map(int, open(0).read().split())
C = [0] * (N + 1)
D = [0] * (N + 1)
for a in A:
	C[a] += 1
	D[C[a]] += 1
T = [0] + [s // i for (i, s) in enumerate(accumulate(D[1:]), 1)]
ans = []
x = N
for k in range(1, N + 1):
	while 0 < x and T[x] < k:
		x -= 1
	ans.append(x)
print('\n'.join(map(str, ans)))


from collections import Counter
from itertools import accumulate
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
cv = Counter(c.values())
max_take = max(cv.keys())
lx = list(accumulate((cv[i] for i in range(max_take + 1))))
rx = list(accumulate((cv[i] * i for i in range(max_take + 1))))
ax = [rx[i] + (lx[-1] - lx[i]) * i for i in range(max_take + 1)]

def bisec(l0, r0, predicate):
	(l, r) = (l0, r0)
	while abs(l - r) > 1:
		mid = (l + r) // 2
		if predicate(mid):
			r = mid
		else:
			l = mid
	return r
for k in range(1, n + 1):
	print(bisec(n + 1, 0, lambda x: x * k <= ax[min(x, max_take)]))


n = int(input())
l = list(map(int, input().split()))
import collections
c = collections.Counter(l)
l = [0] + list(c.values())
c = collections.Counter(l)
l = list(c.items())
l.sort()
l.append((n, 0))
acc = [0 for i in range(n + 2)]
for (i, j) in l:
	acc[i] += j
for i in range(1, n + 1):
	acc[-i - 1] += acc[-i]
ans = [0 for i in range(n + 1)]
t = 0
for (i, j) in zip(l, l[1:]):
	(a, b) = i
	(c, d) = j
	t += a * b
	for i in range(a + 1, c + 1):
		for j in range(acc[i + 1], acc[i] + t // i + 1):
			ans[j] = i
for i in ans[1:]:
	print(i)


from collections import Counter
n = int(input())
c = Counter(map(int, input().split()))
cnt = sorted(c.values())
x = [0] * (n + 1)
ad = [0] * (n + 1)
for i in cnt:
	x[0] += 1
	x[i] -= 1
	ad[i] += i
	ad[-1] -= i
for i in range(n):
	x[i + 1] += x[i]
	ad[i + 1] += ad[i]
b = [0] * (n + 1)
for i in range(n):
	b[i] = x[i] + ad[i] // (i + 1)
prev = 0
ans = [0] * n
for i in reversed(range(n)):
	if prev != b[i]:
		for j in range(prev, b[i]):
			ans[j] = i + 1
		prev = b[i]
print(*ans, sep='\n')


import collections
import bisect
n = int(input())
a = collections.Counter(map(int, input().split()))
a = list(a.values())
a.sort()
b = [0] * len(a)
b[0] = a[0]
for i in range(len(a) - 1):
	b[i + 1] = b[i] + a[i + 1]
s = sum(a)
ans = [i for i in range(0, n + 1)]
ans = ans[::-1]
for t in range(1, n + 1):
	ANS = ans[n + -n // t:]
	for A in ANS:
		z = bisect.bisect_right(a, A)
		if A * t <= (b[z - 1] if z >= 1 else 0) + A * (len(b) - z):
			print(A)
			break


from collections import Counter
from itertools import accumulate
import bisect
n = int(input())
a = list(map(int, input().split()))
c = list(Counter(a).items())
c = list(list(zip(*c))[1])
c.sort()
xls = [0] * (n + 1)
for i in range(1, n + 1):
	geqx = len(c) - bisect.bisect_left(c, i)
	xls[i] = xls[i - 1] + geqx
xlsacc = list(accumulate(xls))
for k in range(1, n + 1):
	l = 0
	r = n + 1
	while l + 1 < r:
		x = (l + r) // 2
		if k * x <= xls[x]:
			l = x
		else:
			r = x
	print(l)


import os
import sys
import numpy as np
if os.getenv('LOCAL'):
	sys.stdin = open('_in.txt', 'r')
sys.setrecursionlimit(2147483647)
INF = float('inf')
IINF = 10 ** 18
MOD = 10 ** 9 + 7
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
C = list(np.bincount(A).tolist())
C.sort()
deleted = 0
S = N

def solve(k):
	nonlocal S, deleted
	k -= deleted
	while k > 0 and C[-1] > S // k:
		S -= C.pop()
		deleted += 1
		k -= 1
	if k > 0:
		return S // k
	return 0
for k in range(1, N + 1):
	print(solve(k))


N = int(input())
A = list(map(int, input().split()))
A.sort()
D = [1]
t = A[0]
for i in range(1, N):
	if A[i] == t:
		D[-1] += 1
	else:
		D.append(1)
		t = A[i]
D.sort()
L = len(D)
S = [0] * L
S[0] = D[0]
for i in range(1, L):
	S[i] = S[i - 1] + D[i]

def hersCode(n):
	ok = 0
	ng = N + 1
	while abs(ok - ng) > 1:
		mid = abs(ok + ng) // 2
		if nasu(mid, n):
			ok = mid
		else:
			ng = mid
	return ok

def honya(n):
	ok = -1
	ng = L
	while abs(ok - ng) > 1:
		mid = abs(ok + ng) // 2
		if D[mid] >= n:
			ok = mid
		else:
			ng = mid
	return ok + 1

def nasu(x, n):
	a = honya(x)
	ans = a * x + S[L - a - 1]
	if ans >= n * x:
		return True
	else:
		return False
D.sort(reverse=True)
for i in range(1, N + 1):
	if L < i:
		print(0)
		continue
	print(hersCode(i))


N = int(input())
A = list(map(int, input().split()))
from collections import Counter
from bisect import bisect
vs = list(Counter(A).values())
vs.sort()
cums = [0]
for v in vs:
	cums.append(cums[-1] + v)

def is_ok(k, m):
	j = bisect(vs, m)
	z = cums[j] + m * (len(vs) - j)
	return z >= m * k
ans = []
for k in range(1, N + 1):
	if k > len(vs):
		ans.append(0)
	else:
		ok = 0
		ng = N // k + 1
		while ng - ok > 1:
			m = (ok + ng) // 2
			if is_ok(k, m):
				ok = m
			else:
				ng = m
		ans.append(ok)
print(*ans, sep='\n')


from collections import *
MAX = 3 * pow(10, 5) + 2
n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(MAX)]
c = [0 for i in range(MAX)]
for i in a:
	b[i] += 1
for i in b:
	c[i] += 1
s = n
last = n
print(last)
for k in range(2, n + 1):
	while s // k < last:
		best = min(last, s // k)
		for i in range(last, best, -1):
			s -= c[i]
			c[i - 1] += c[i]
			c[i] = 0
		last = best
	print(last)


import bisect as b
n = int(input())
d = [0] * n
for el in map(int, input().split()):
	d[el - 1] += 1
d.sort()
s = [0] * (n + 1)
for i in range(n):
	s[i + 1] = s[i] + d[i]
for k in range(1, n + 1):
	l = 0
	r = n // k + 1
	while l + 1 < r:
		c = (l + r) // 2
		i = b.bisect_left(d, c)
		total = s[i] + c * (n - i)
		if total >= k * c:
			l = c
		else:
			r = c
	print(l)