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