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

ans = 0
if P[0] == 1:
  ans += 1
  tmp_p = P[0]
  P[0] = P[1]
  P[1] = tmp_p

if P[N-1] == N:
  ans += 1
  tmp_p = P[N-1]
  P[N-1] = P[N-2]
  P[N-2] = tmp_p


for i in range(1,N-1):
  if P[i] != i+1:
    continue
  else:
    ans += 1
    if P[i-1] != i:
      tmp_p = P[i]
      P[i] = P[i-1]
      P[i-1] = tmp_p
    else:
      tmp_p = P[i]
      P[i] = P[i+1]
      P[i+1] = tmp_p  
print(ans)