n = int(input())
a = [int(x) for x in input().split()]
b = [0] * max(a)
for i in range(n):
    b[a[i]-1] += 1
k = 0
while sum(b)>0:
    b[len(b)-1] -= 1
    k += len(b)
    #print(b)
    for i in range(1,len(b)-1):
        b[i-1] = b[i]
        b[i] = 0
    #print(b)
    if len(b) > 0:
        i = len(b) - 1
        while b[i] == 0 and i>0:
            b.pop(i)
            i -= 1
    #print(b)
    #print(k)
print(k-1)