1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import numpy as np

n = int(input())
a = np.array(input().split(), int)

# n = 1000000
# a = np.random.randint(n, size=n)

unique, counts = np.unique(a, return_counts=True)

counts[::-1].sort()

programResult = ""

for clientsCountI in range(1, n + 1):
    try:
        lastIndex = (np.argwhere(counts >= clientsCountI)[-1][0])
        programResult += f"{str(np.sum(clientsCountI * (counts / clientsCountI).astype(int)))} "
    except IndexError:
        programResult += "0 " * (n - clientsCountI + 1)
        break

print(programResult.strip())