N = int(input()) ans = 0 A = list(map(int, input().split())) for a in A: if a - 1 not in A: ans += a print(ans)