n=int(input()) a=list(map(int,input().split())) c=a[0] d=0 for i in range(1,len(a)): if c!=a[i]+1: d+=1 else: c=a[i] print(d)