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