# -*- coding: utf-8 -*-

n = int(eval(input()))

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



i = 0

ans = 0

while True:

    if p[i] == i + 1:

        p[i], p[i + 1] = p[i + 1], p[i]

        ans += 1

        i += 1

    else:

        i += 1

    if i == n - 1:

        if p[i] == i + 1:

            ans += 1

        break

print(ans)

# -*- coding: utf-8 -*-

n = int(eval(input()))

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



ans = 0

for i in range(n - 1):

    if p[i] == i + 1:

        p[i], p[i + 1] = p[i + 1], p[i]

        ans += 1

if p[-1] == n:

    ans += 1

print(ans)

# -*- coding: utf-8 -*-
n = int(eval(input()))
p = list(map(int, input().split()))
i = 0
ans = 0
while True:
    if p[i] == i + 1:
        p[i], p[i + 1] = p[i + 1], p[i]
        ans += 1
        i += 1
    else:
        i += 1
    if i == n - 1:
        if p[i] == i + 1:
            ans += 1
        break
print(ans)

# -*- coding: utf-8 -*-
n = int(eval(input()))
p = [int(i) for i in input().split()]
ans = 0
for i in range(n - 1):
    if p[i] == i + 1:
        p[i], p[i + 1] = p[i + 1], p[i]
        ans += 1
if p[-1] == n:
    ans += 1
print(ans)

-p = list(map(int, input().split())) -i = 0 +p = [int(i) for i in input().split()] -while True: +for i in range(n - 1): -        i += 1 -    else: -        i += 1 -    if i == n - 1: -        if p[i] == i + 1: -            ans += 1 -        break +if p[-1] == n: +    ans += 1