n=int(eval(input()))

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

for i in range(n):

    a[i]-=1

ans=0

for i in range(n-1):

    if a[i]==i and a[i+1]==i+1:

        ans+=1

        a[i],a[i+1]=i+1,i

    if a[i]==i:

        ans+=1

if a[-1]==n-1:

    ans+=1

print(ans)
n=int(eval(input()))

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

ans=0

for i in range(n-1):

    if a[i]==i+1:

        a[i],a[i+1]=a[i+1],a[i]

        ans+=1

if a[-1]==n:

    ans+=1

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

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

-for i in range(n): -    a[i] -= 1 -    if a[i] == i and a[i + 1] == i + 1: +    if a[i] == i + 1: +        a[i], a[i + 1] = a[i + 1], a[i] -        a[i], a[i + 1] = i + 1, i -    if a[i] == i: -        ans += 1 -if a[-1] == n - 1: +if a[-1] == n: