n = int(input()) A = sorted(list(map(int,input().split())),reverse=True) for i in range(n-1): if A[i] - 1 == A[i+1]: A[i] = 0 print(sum(A))