#!/usr/bin/env python3 # from typing import * import sys import io import math import collections import decimal import itertools import bisect import heapq def input(): return sys.stdin.readline()[:-1] # sys.setrecursionlimit(1000000) # _INPUT = """# paste here... # """ # sys.stdin = io.StringIO(_INPUT) INF = 10**10 N = int(input()) A = list(map(int, input().split())) s = set(A) ans = 0 for a in A: if a-1 not in s: ans += a print(ans)