n=int(eval(input()))

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

f=[True if a[i]==i+1 else False for i in range(n)]

ans=0

for i in range(n-1):

    if f[i] and f[i+1]:

        f[i]=False

        f[i+1]=False

        ans+=1



ans+=sum(f)

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

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

f=[True if a[i]==i+1 else False for i in range(n)]

ans=0

for i in range(n-1):

    if f[i]:

        f[i]=False

        f[i+1]=False

        ans+=1



if f[n-1]:

    ans+=1

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

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

-    if f[i] and f[i + 1]: +    if f[i]: -ans += sum(f) +if f[n - 1]: +    ans += 1