N = int(input()) l =[] for i in range(N): l.append(int(input())) l.sort() ans = 0 for i in range(N-2): if l[i + 1] - l[i] <= 1: ans +=1 if l[N-1] - l[N-2] <= 1: ans += 2 else: ans += 1 print(ans)