n=int(eval(input()))

p=[int(i) for i in input().split()]

cnt=0

for i in range(n-1):

	if p[i]==i+1:

		p[i],p[i+1]=p[i+1],p[i]

		cnt+=1

if p[-1]==n:cnt+=1

print(cnt)
n,*p=list(map(int,open(0).read().split()))

i=c=0

while i<n:

	if p[i]==i+1:

		i+=1

		c+=1

	i+=1

print(c)
n = int(eval(input()))
p = [int(i) for i in input().split()]
cnt = 0
for i in range(n - 1):
    if p[i] == i + 1:
        p[i], p[i + 1] = p[i + 1], p[i]
        cnt += 1
if p[-1] == n:
    cnt += 1
print(cnt)

n, *p = list(map(int, open(0).read().split()))
i = c = 0
while i < n:
    if p[i] == i + 1:
        i += 1
        c += 1
    i += 1
print(c)

-n = int(eval(input())) -p = [int(i) for i in input().split()] -cnt = 0 -for i in range(n - 1): +n, *p = list(map(int, open(0).read().split())) +i = c = 0 +while i < n: -        p[i], p[i + 1] = p[i + 1], p[i] -        cnt += 1 -if p[-1] == n: -    cnt += 1 -print(cnt) +        i += 1 +        c += 1 +    i += 1 +print(c)