n=int(eval(input()))

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

sousa=0

flag=True

for i in range(n):

  if i+1==p[i]:

    if flag:

      sousa+=1

      flag=False

    else:

      flag=True

  else:

    flag=True

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

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

sousa=0

flag=False

for i in range(n):

  if flag:

    flag=False

    continue

  if i+1==p[i]:

    sousa+=1

    flag=True

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

n = int(eval(input()))
p = list(map(int, input().split()))
sousa = 0
flag = False
for i in range(n):
    if flag:
        flag = False
        continue
    if i + 1 == p[i]:
        sousa += 1
        flag = True
print(sousa)

-flag = True +flag = False +    if flag: +        flag = False +        continue -        if flag: -            sousa += 1 -            flag = False -        else: -            flag = True -    else: +        sousa += 1