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
def solution(arr):
    size = len(arr)
    s = 0
    c = 0
    count = {}
    for i in arr:
        if i in count:
            count[i] += 1
        else:
            count[i] = 1

    count = sorted(count.items(), key=lambda x: x[1], reverse=True)

    for i in count:
        s = s + i[1] + (i[1] - 1)
        if s >= size:
            return c+1
        c += 1
        
    return 0

if __name__ == "__main__":
    n = int(input())
    arr = list(map(int, input().split()))
    print(solution(arr))