n = int(input()) a = list(map(int,input().split())) s = set(a) ans = 0 for i in a : if i-1 not in s : ans += a print(ans)