n=int(input()) a=list(map(int,input().split())) a.sort() m=0 b=a[n-1] for i in range(n-1): if a[i]!=b: m=m+a[i] print(m)