import collections N = int(input()) A = list(map(int, input().split())) CA = collections.Counter(A) ans=0 for k in CA.keys(): if CA[k-1]==0: ans+=k print(ans)