N = int(eval(input()))

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



ans = 0

for i in range(N):

  if i < N - 1 and p[i] == i + 1:

    p[i] = p[i+1]

    p[i+1] = i+1

    ans += 1

  elif i == N -1 and p[i] == i+1:

    p[i] = p[i-1]

    p[i-1] = i + 1

    ans += 1

print(ans)
N = int(eval(input()))

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

ans = 0

for i in range(N):

    if p[i]-1 == i:

        if i + 1 <= N-1:

            p[i] = p[i+1]

            p[i+1] = i + 1

            ans += 1

        elif i - 1 >= 0:

            p[i] = p[i-1]

            p[i-1] = i + 1

            ans += 1

print(ans)
N = int(eval(input()))
p = [int(x) for x in input().split()]
ans = 0
for i in range(N):
    if i < N - 1 and p[i] == i + 1:
        p[i] = p[i + 1]
        p[i + 1] = i + 1
        ans += 1
    elif i == N - 1 and p[i] == i + 1:
        p[i] = p[i - 1]
        p[i - 1] = i + 1
        ans += 1
print(ans)

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

-p = [int(x) for x in input().split()] +p = list(map(int, input().split())) -    if i < N - 1 and p[i] == i + 1: -        p[i] = p[i + 1] -        p[i + 1] = i + 1 -        ans += 1 -    elif i == N - 1 and p[i] == i + 1: -        p[i] = p[i - 1] -        p[i - 1] = i + 1 -        ans += 1 +    if p[i] - 1 == i: +        if i + 1 <= N - 1: +            p[i] = p[i + 1] +            p[i + 1] = i + 1 +            ans += 1 +        elif i - 1 >= 0: +            p[i] = p[i - 1] +            p[i - 1] = i + 1 +            ans += 1