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
if __name__ == "__main__":
    n = input()
    arr_in = input()
    arr = [int(elem) for elem in arr_in.split()]
    counters = [0] * int(n)
    
    for _, x in enumerate(arr):
        counters[x-1] += 1
    counters.sort(reverse = True)
    out, idx_front, idx_tail = 0, 0, int(n) - 1
    while True:
        out += 1
        lid_count = counters[idx_front] - 1
        while lid_count > 0 and idx_front < idx_tail:
            if lid_count <= counters[idx_tail]:
                counters[idx_tail] -= lid_count
                counters[idx_front] = 0
                lid_count = 0
                break
            else:
                lid_count -= counters[idx_tail]
                counters[idx_front] -= counters[idx_tail]
                idx_tail -= 1
    
        if idx_front >= idx_tail:
            break
        
        idx_front +=1
        if counters[idx_front] == 0:
            break
    print(out)