n = int(input()) a = list(map(int, input().split())) x = [0] * 200000 for i in range(n): x[a[i] - 1] = x[a[i] - 1] + 1 for i in range(199998): j = 199997 - i if x[j] > 0: x[j] += x[j + 2] ans = n for i in range(200000): if i > 0 and x[i - 1] > 0 and x[i] > 0: ans += x[i] print(ans)