import sys
import bisect
input = sys.stdin.readline

N = int(input())
L = [int(v) for v in input().split()]

t = [0] * N
for i in range(N):
    t[i] = i - L[i] + 1

index = 0
c = 0
while index < N:
    if index + 1 < N and t[index] == 0 and t[index + 1] == 0:
        t[index] = -1
        t[index + 1] = 1
        c += 1
        index += 2
    elif index + 1 < N and t[index] == 0 and t[index + 1] < 0:
        c += 1
        t[index] = t[index + 1] - 1
        t[index + 1] = 1
        index += 2
    elif  index - 1 >= 0 and t[index] == 0 and t[index - 1] > 0:
        c += 1
        t[index] = t[index - 1] + 1
        t[index] = -1
        index += 2
    else:
        index += 1

print(c)