n=int(eval(input()))

arr=list(map(int,input().split()))

ans=0

for i in range(n-2):

  if arr[i]==i+1:

    arr[i],arr[i+1]=arr[i+1],arr[i]

    ans+=1

  elif arr[i+1]==i+1:

    arr[i+1],arr[i+2]=arr[i+2],arr[i+1]

if arr[-1]==n or arr[-2]==n-1:

  ans+=1

print(ans)

n=int(eval(input()))

arr=list(map(int,input().split()))

ans=0

for i in range(n-1,-1,-1):

  if arr[i]==i+1:

    arr[i],arr[i-1]=arr[i-1],arr[i]

    ans+=1

print(ans)
n = int(eval(input()))
arr = list(map(int, input().split()))
ans = 0
for i in range(n - 2):
    if arr[i] == i + 1:
        arr[i], arr[i + 1] = arr[i + 1], arr[i]
        ans += 1
    elif arr[i + 1] == i + 1:
        arr[i + 1], arr[i + 2] = arr[i + 2], arr[i + 1]
if arr[-1] == n or arr[-2] == n - 1:
    ans += 1
print(ans)

n = int(eval(input()))
arr = list(map(int, input().split()))
ans = 0
for i in range(n - 1, -1, -1):
    if arr[i] == i + 1:
        arr[i], arr[i - 1] = arr[i - 1], arr[i]
        ans += 1
print(ans)

-for i in range(n - 2): +for i in range(n - 1, -1, -1): -        arr[i], arr[i + 1] = arr[i + 1], arr[i] +        arr[i], arr[i - 1] = arr[i - 1], arr[i] -    elif arr[i + 1] == i + 1: -        arr[i + 1], arr[i + 2] = arr[i + 2], arr[i + 1] -if arr[-1] == n or arr[-2] == n - 1: -    ans += 1