n = int(input())

count = 0

res = 0

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



for i in range(n + 1):

	if (ais[i] if i < n else -1) != i + 1:

		#flush the count

		res += (count + 1)/2# + 1

		count = 0

	else:

		count +=1

print(res)
n = int(input())

count,res,ais,i = 0,0, list(map(int , input().split())),0

while(i < n+1):

	if (ais[i] if i < n else -1) != i + 1:

		res += (count + 1)/2# + 1

		count = 0

	else: count +=1

	i+=1

print(res)
n = int(input())
count = 0
res = 0
ais = list(map(int, input().split()))
for i in range(n + 1):
    if (ais[i] if i < n else -1) != i + 1:
        # flush the count
        res += (count + 1) / 2  # + 1
        count = 0
    else:
        count += 1
print(res)

n = int(input())
count, res, ais, i = 0, 0, list(map(int, input().split())), 0
while i < n + 1:
    if (ais[i] if i < n else -1) != i + 1:
        res += (count + 1) / 2  # + 1
        count = 0
    else:
        count += 1
    i += 1
print(res)

-count = 0 -res = 0 -ais = list(map(int, input().split())) -for i in range(n + 1): +count, res, ais, i = 0, 0, list(map(int, input().split())), 0 +while i < n + 1: -        # flush the count +    i += 1