N = int(input()) A = list(map(int,input().split())) s = set() for i in range(N): s.add(A[i]) count = 0 for i in range(N): if not A[i]-1 in s: count += A[i] print(count)