# https://qiita.com/fumitoh/items/3b677522e24ac0235bd0 import itertools N = int(input()) A = sorted([int(x) for x in input().split()]) group = [list(g) for _, g in itertools.groupby(A, key=lambda n, c=itertools.count(): n - next(c))] # print(A) # print(group) # result = 0 # for x in group: # result += x[0] print(sum([x[0] for x in group]))