n = int(input()) a = map(int, input().split()) a = list(a) a.sort() res = a[0] for i in range(1, n): if a[i - 1] + 1 != a[i]: res += a[i] print(res)