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