N = int(input().strip()) A = list(map(int, input().strip().split(' '))) ans = 0 for i in A: ans += 0 if i - 1 in A else i print(ans)