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
#!/usr/bin/python3


n = int(input())
original_sequence = [int(a) for a in input().split()]
assert(len(original_sequence) == n)

def solve():
    kub = [0] * (n+10)
    for a in original_sequence:
        kub[a] += 1

    kub.sort(reverse=True)
    while kub[-1] == 0:
        kub.pop()
    #print(kub)

    wyn = 0
    left = sum(kub)
    pojemnosc = 0
    for licznosc in kub:
        wyn += 1
        left -= licznosc
        pojemnosc += licznosc - 1
        if pojemnosc >= left:
            return wyn
    
    # Wynikiem jest liczba rodzajów elementów
    return wyn


print(solve())