n=int(input()) a=list(map(int,input().split())) a.sort() ans=0 for i in range(1,n): if a[i]==a[i-1]+1: pass else : ans+=a[i] ans=ans+a[0] print(ans)