input() a= list(map(int,input().split())) maxn = max(a) s = 0 for x in a: if x != maxn: s += x print(s)