N=int(input()) A=list(map(int,input().split())) B=set(A) X=N for a in A: if a+1 in B: X+=1 else: continue b=a+1 while b+2 in B: X+=1 b+=2 print(X)