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