N=int(input()) R=list(map(int,input().split())) dist = [N]*N dist[0]=0 for i,r in enumerate(R): for j in range(i+1,r): dist[j] = min(dist[j],dist[i]+1) print(dist[-1])