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