n = int(input()) A = list(map(int, input().split())) A.sort() sumv = A[0] for i in range(n-1): if A[i+1] - 1 != A[i]: sumv += A[i+1] print(sumv)