n = int(eval(input()))

p = list(map(int, input().split())) + [0]

cnt = 0

j = False



for i in range(n):

    if p[i] == i + 1:

        cnt += 1

        if p[i + 1] == i + 2:

            if j == False:

                cnt -= 1

                j = True

            else:

                j = False

    else:

        j = False

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

p = list(map(int, input().split())) + [0]

cnt = 0

i = 0



while i < n:

    if p[i] == i + 1:

        cnt += 1

        i += 1

    i += 1



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

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

-j = False -for i in range(n): +i = 0 +while i < n: -        if p[i + 1] == i + 2: -            if j == False: -                cnt -= 1 -                j = True -            else: -                j = False -    else: -        j = False +        i += 1 +    i += 1