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