N = int(eval(input()))

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

# p_swap = [-1]*N

ans = 0

for i in range(N-1):

    if i+1 == ps[i]:

        p1,p2 = ps[i:i+2]

        ps[i] = p2

        ps[i+1] = p1

        ans += 1

if ps[N-1] == N:

    ans += 1

print(ans)
# 前から順番に後ろに向けてswap

n = int(eval(input()))

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



cnt = 0

for i in range(n-1):

    if i + 1 == ps[i]:

        tmp = ps[i]

        ps[i] = ps[i+1]

        ps[i+1] = tmp

        cnt += 1

# 最後残っていたら直前とswap

if ps[n-1] == n:

    cnt += 1



print(cnt)

N = int(eval(input()))
ps = list(map(int, input().split()))
# p_swap = [-1]*N
ans = 0
for i in range(N - 1):
    if i + 1 == ps[i]:
        p1, p2 = ps[i : i + 2]
        ps[i] = p2
        ps[i + 1] = p1
        ans += 1
if ps[N - 1] == N:
    ans += 1
print(ans)

# 前から順番に後ろに向けてswap
n = int(eval(input()))
ps = list(map(int, input().split()))
cnt = 0
for i in range(n - 1):
    if i + 1 == ps[i]:
        tmp = ps[i]
        ps[i] = ps[i + 1]
        ps[i + 1] = tmp
        cnt += 1
# 最後残っていたら直前とswap
if ps[n - 1] == n:
    cnt += 1
print(cnt)

-N = int(eval(input())) +# 前から順番に後ろに向けてswap +n = int(eval(input())) -# p_swap = [-1]*N -ans = 0 -for i in range(N - 1): +cnt = 0 +for i in range(n - 1): -        p1, p2 = ps[i : i + 2] -        ps[i] = p2 -        ps[i + 1] = p1 -        ans += 1 -if ps[N - 1] == N: -    ans += 1 -print(ans) +        tmp = ps[i] +        ps[i] = ps[i + 1] +        ps[i + 1] = tmp +        cnt += 1 +# 最後残っていたら直前とswap +if ps[n - 1] == n: +    cnt += 1 +print(cnt)