N = int(input()) A = list(map(int, input().split())) X = [0] * 100 for a in A: X[a] = 1 ans = 0 for a in A: if X[a-1] == 0: ans += a print(ans)