n=int(input()) l=list(map(int,input().split())) ans=0 for x in l: if x-1 not in l: ans+=x print(ans)