n = int(input()) a = list(map(int, input().split())) score = 0 for i in a: if not i-1 in a: score += i print(score)