N=int(input()) A=sorted(map(int,input().split())) ANS=0 for i in range(N): if not(A[i]-1 in A): ANS+=A[i] print(ANS)