b = int(input()) a = list(map(int,input().split())) c = 0 for _ in range(b): if a[_] != max(a): c = c + a[_] print(c)