a=[] i=0 k=int(input()) A=input().split() a=list(map(int,A)) a.sort() p=a[0] while i <= k-2: if a[i]+1!=a[i+1]: p+=a[i+1] i+=1 print(p)