n = int(eval(input()))

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

 

t = 0

for i in range(n):

    if a[i] == i+1:

        t += 1



i = 0

cnt = 0

while i < n-1:

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

        cnt += 1

        i += 2

    else:

        i += 1



print((t-cnt))
n = int(eval(input()))

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



cnt = 0

i = 0

while i < n:

    if a[i] == i+1:

        cnt += 1

        i += 2

    else:

        i += 1

 

print(cnt)
n = int(eval(input()))
a = list(map(int, input().split()))
t = 0
for i in range(n):
    if a[i] == i + 1:
        t += 1
i = 0
cnt = 0
while i < n - 1:
    if a[i] == i + 1 and a[i + 1] == i + 2:
        cnt += 1
        i += 2
    else:
        i += 1
print((t - cnt))

n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 0
i = 0
while i < n:
    if a[i] == i + 1:
        cnt += 1
        i += 2
    else:
        i += 1
print(cnt)

-t = 0 -for i in range(n): +cnt = 0 +i = 0 +while i < n: -        t += 1 -i = 0 -cnt = 0 -while i < n - 1: -    if a[i] == i + 1 and a[i + 1] == i + 2: -print((t - cnt)) +print(cnt)