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