from copy import deepcopy

N=int(input())
p=list(map(int,input().split()))

count1=0
p1=deepcopy(p)
for i in range(N-1):
  if p1[i] == i+1:
    p1[i],p1[i+1]=p1[i+1],p1[i]
    count1 += 1
    
count2=0
p2=deepcopy(p)
for i in range(N-1,0,-1):
  if p2[-i] == N-i:
    p2[-i],p2[-i-1]=p2[-i-1],p2[-i]
    count2 += 1
    
print(min(count1,count2))