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