n = int(input())
p = list(map(int, input().split()))
dp = [p[i] - (i+1) for i in range(n)]
#print(dp)
cnt = 0
for i in range(n-1):
    if dp[i] != 0:
        continue
    dp[i+1], dp[i] = dp[i]-1, dp[i+1]+1
    cnt += 1
print(cnt)