N=int(input()) A=list(map(int,input().split())) S=set(A) ans=0 for a in A: if not a-1 in S: ans+=a print(ans)