n = int(input()) a = list(map(int, input().split())) s = set(a) total = 0 for num in a: if (num - 1) not in s: total += num print(total)