from sys import stdin n, *a = map(int, stdin.read().split()) a.sort() ans = 0 last = -1 for i in range(n): if a[i] - 1 != last: ans += a[i] last = a[i] print("{}".format(ans))