n = int(input()) a = list(map(int,input().split())) res = 0 for ele in a: if ele != max(a): res +=ele print(res)