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