N = int(eval(input()))

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



ls = [""] * N

cnt = 0



for i in range(N):

  if P[i] == i + 1:

    ls[i] = "#"

  else:

    ls[i] = "."

    

if ls[-1] == "#":

  if ls[-2] == "#":

    ls[-1], ls[-2] = ".", "."

  else:

    ls[-1] = "."

  cnt += 1



for j in range(N-1):

  if ls[j] == "#":

    if ls[j+1] == "#":

      ls[j+1] = "."

    cnt += 1

    

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

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



ans = 0



if P[-1] == N:

  ans += 1

  P[-1] = -1

  if P[-2] == N - 1:

    P[-2] = -1



for i in range(N-1):

  if P[i] == i + 1:

    ans += 1

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

      P[i+1] = -1

      

print(ans)
N = int(eval(input()))
P = list(map(int, input().split()))
ls = [""] * N
cnt = 0
for i in range(N):
    if P[i] == i + 1:
        ls[i] = "#"
    else:
        ls[i] = "."
if ls[-1] == "#":
    if ls[-2] == "#":
        ls[-1], ls[-2] = ".", "."
    else:
        ls[-1] = "."
    cnt += 1
for j in range(N - 1):
    if ls[j] == "#":
        if ls[j + 1] == "#":
            ls[j + 1] = "."
        cnt += 1
print(cnt)

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

-ls = [""] * N -cnt = 0 -for i in range(N): +ans = 0 +if P[-1] == N: +    ans += 1 +    P[-1] = -1 +    if P[-2] == N - 1: +        P[-2] = -1 +for i in range(N - 1): -        ls[i] = "#" -    else: -        ls[i] = "." -if ls[-1] == "#": -    if ls[-2] == "#": -        ls[-1], ls[-2] = ".", "." -    else: -        ls[-1] = "." -    cnt += 1 -for j in range(N - 1): -    if ls[j] == "#": -        if ls[j + 1] == "#": -            ls[j + 1] = "." -        cnt += 1 -print(cnt) +        ans += 1 +        if P[i + 1] == i + 2: +            P[i + 1] = -1 +print(ans)