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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
n = int(input())
sequence = [int(i) for i in input().split(' ')]

result = 0
repeats = []

for number in dict.fromkeys(sequence):
    count = sequence.count(number)
    repeats.append([number, count])

new_repeats = repeats.copy()

while len(repeats) > 0:
    max_repeats = 0
    min_repeats = None

    for repeat in repeats:
        if repeat[1] > max_repeats:
            max_repeats = repeat[1]
        if min_repeats is None:
            min_repeats = max_repeats
        if repeat[1] < min_repeats:
            min_repeats = repeat[1]

    for i in range(len(repeats)):
        if max_repeats == min_repeats:
            result += 1
            new_repeats.remove(repeats[i])
            for j in range(0, len(repeats)):
                if new_repeats.count(repeats[j]) != 0:
                    new_repeats.remove(repeats[j])
                    for l in range(0, repeats[j][1] - (repeats[i][1] - 1)):
                        new_repeats.append([repeats[j][0], 1])
                    break
            else:
                break
            break
        if repeats[i][1] == max_repeats:
            result += 1
            new_repeats.remove(repeats[i])
            for l in range(max_repeats - 1):
                for j in range(0, len(repeats)):
                    if repeats[j][1] == min_repeats and new_repeats.count(repeats[j]) != 0:
                        new_repeats.remove(repeats[j])
                        break
                else:
                    break
            else:
                break

    repeats = new_repeats.copy()
print(int(result))