n = int(input()) ls = list(map(int,input().split())) ls.sort() c = 0 h = 0 for i in ls: if i-h > 1: c += i h = i print(c)