from collections import Counter N = int(input()) A = list(map(int, input().split())) counter = Counter(A) ans = 0 for key, value in counter.items(): if not counter[key-1]: ans += value * key print(ans)