n = int(eval(input()))

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



x = []



for i in range(n):

    if p[i] - 1 == i:

        x.append('x')

    else:

        x.append('o')



cnt = 0

for i in range(n-1):

    if x[i] == "x" and x[i+1] == 'o':

        cnt += 1

    elif x[i] == "x" and x[i+1] == 'x':

        cnt += 1

        x[i+1] = 'o'



if x[n-1] == "x":

    cnt += 1



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

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



ans = 0

for i in range(n-1):

    if p[i]-1 == i:

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

        ans += 1



if p[-1] == n:

    ans+=1



print(ans)
n = int(eval(input()))
p = list(map(int, input().split()))
x = []
for i in range(n):
    if p[i] - 1 == i:
        x.append("x")
    else:
        x.append("o")
cnt = 0
for i in range(n - 1):
    if x[i] == "x" and x[i + 1] == "o":
        cnt += 1
    elif x[i] == "x" and x[i + 1] == "x":
        cnt += 1
        x[i + 1] = "o"
if x[n - 1] == "x":
    cnt += 1
print(cnt)

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

-x = [] -for i in range(n): +ans = 0 +for i in range(n - 1): -        x.append("x") -    else: -        x.append("o") -cnt = 0 -for i in range(n - 1): -    if x[i] == "x" and x[i + 1] == "o": -        cnt += 1 -    elif x[i] == "x" and x[i + 1] == "x": -        cnt += 1 -        x[i + 1] = "o" -if x[n - 1] == "x": -    cnt += 1 -print(cnt) +        p[i], p[i + 1] = p[i + 1], p[i] +        ans += 1 +if p[-1] == n: +    ans += 1 +print(ans)