#coding: utf-8
N = int(raw_input())
P = map(int, raw_input().split(' '))

pos = [0] * N
for i, p in enumerate(P):
    pos[p - 1] = p - 1 - i

swap = 0
while 0 in pos:
    for i, p in enumerate(P):
        if pos[p - 1] == 0:
            if i == 0:
                pos[P[i] - 1] -= 1
                pos[P[i + 1] - 1] += 1
                P[i], P[i + 1] = P[i + 1], P[i]
            elif i == N - 1:
                pos[P[i] - 1] += 1
                pos[P[i - 1] - 1] -= 1
                P[i], P[i - 1] = P[i - 1], P[i]
            else:
                if P[i - 1] <= 0:
                    pos[P[i] - 1] += 1
                    pos[P[i - 1] - 1] -= 1
                    P[i], P[i - 1] = P[i - 1], P[i]
                elif P[i + 1] >= 0:
                    pos[P[i] - 1] -= 1
                    pos[P[i + 1] - 1] += 1
                    P[i], P[i + 1] = P[i + 1], P[i]
                else:
                    left_val = abs(P[i - 1])
                    right_val = abs(P[i + 1])
                    if left_val > right_val:
                        pos[P[i] - 1] += 1
                        pos[P[i - 1] - 1] -= 1
                        P[i], P[i - 1] = P[i - 1], P[i]
                    else:
                        pos[P[i] - 1] -= 1
                        pos[P[i + 1] - 1] += 1
                        P[i], P[i + 1] = P[i + 1], P[i]
            swap += 1
print swap