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
import sys
from collections import Counter

n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))

d = Counter()
for v in a:
    d[v] += 1


ll = sorted(d.values(), reverse=True)
# print(ll)

s = 0
e = len(ll)-1
r = 0
while s <= e:
    if ll[s] <= 0:
        break
    if ll[s] == 1:
        r += e-s+1
        break
    m = ll[s] - 1
    while m > 0 and e > s:
        if ll[e] <= m:
            m -= ll[e]
            e -= 1
        else:
            ll[e] = ll[e] - m
            break
    s += 1
    r += 1

print(r)