N = int(eval(input()))

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



cnt = 0

t = 'o' if P[0] == 1 else 'x'

j = 0 if t == 'o' else 1

L = []

for i, p in enumerate(P):

    s = 'o' if p == (i + 1) else 'x'

    if s == t:

        cnt += 1

    else:

        L.append(cnt)

        cnt = 1

        t = s

L.append(cnt)



ans = 0

for i, n in enumerate(L):

    if i % 2 == j:

        ans += (n + 2 - 1) // 2



print(ans)

N = int(eval(input()))

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



cnt = 0

ans = 0

t = 'o' if P[0] == 1 else 'x'

for i, p in enumerate(P):

    s = 'o' if p == (i + 1) else 'x'

    if s == t:

        cnt += 1

    else:

        if t == 'o':

            ans += (cnt + 2 - 1) // 2

        cnt = 1

        t = s

else:

    if t == 'o':

        ans += (cnt + 2 - 1) // 2



print(ans)

N = int(eval(input()))
P = list(map(int, input().split()))
cnt = 0
t = "o" if P[0] == 1 else "x"
j = 0 if t == "o" else 1
L = []
for i, p in enumerate(P):
    s = "o" if p == (i + 1) else "x"
    if s == t:
        cnt += 1
    else:
        L.append(cnt)
        cnt = 1
        t = s
L.append(cnt)
ans = 0
for i, n in enumerate(L):
    if i % 2 == j:
        ans += (n + 2 - 1) // 2
print(ans)

N = int(eval(input()))
P = list(map(int, input().split()))
cnt = 0
ans = 0
t = "o" if P[0] == 1 else "x"
for i, p in enumerate(P):
    s = "o" if p == (i + 1) else "x"
    if s == t:
        cnt += 1
    else:
        if t == "o":
            ans += (cnt + 2 - 1) // 2
        cnt = 1
        t = s
else:
    if t == "o":
        ans += (cnt + 2 - 1) // 2
print(ans)

+ans = 0 -j = 0 if t == "o" else 1 -L = [] -        L.append(cnt) +        if t == "o": +            ans += (cnt + 2 - 1) // 2 -L.append(cnt) -ans = 0 -for i, n in enumerate(L): -    if i % 2 == j: -        ans += (n + 2 - 1) // 2 +else: +    if t == "o": +        ans += (cnt + 2 - 1) // 2