N = int(input()) A = list(map(int, input().split())) lst = [True] * 100 for a in A: lst[a] = False ans = 0 for i in range(max(A) - 1, min(A) - 2, -1): # print(f"idx = {i}") if lst[i] and not lst[i + 1]: # print(i) ans += i + 1 print(ans)