N = int(eval(input()))

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



ans = 0

if P[-1] == N:

    tmp = P[-1]

    P[-1] = P[-2]

    P[-2] = tmp

    ans += 1



for i in range(N-1):

    if P[i] == i+1:

        tmp = P[i]

        P[i] = P[i+1]

        P[i+1] = tmp

        ans += 1





for i in range(N):

    if P[i] == i+1:

        ans += 1



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

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



ans = 0

i = 0

while i < N:

    if P[i] == i + 1:

        ans += 1

        i += 1

    i += 1



print(ans)

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

N = int(eval(input()))
P = list(map(int, input().split()))
ans = 0
i = 0
while i < N:
    if P[i] == i + 1:
        ans += 1
        i += 1
    i += 1
print(ans)

-if P[-1] == N: -    tmp = P[-1] -    P[-1] = P[-2] -    P[-2] = tmp -    ans += 1 -for i in range(N - 1): -    if P[i] == i + 1: -        tmp = P[i] -        P[i] = P[i + 1] -        P[i + 1] = tmp -        ans += 1 -for i in range(N): +i = 0 +while i < N: +        i += 1 +    i += 1