a = int(input()) b = list(map(int, input(). split())) s = 0 for x in range(a): s = s + b[x] c = s -min(b) print(c)