#include <iostream>
#include <queue>
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> P(N);
    for(auto &p:P) cin>>p;
    vector<int> D(N,1000000);
    queue<int> Q;
    D[0]=0;
    Q.push(0);
    while(!Q.empty()){
        int x = Q.front(); Q.pop();
        if(P[x]==0){
            for(int d=1;d<=6&&x+d<N;d++){
                if(D[x+d]>D[x]+1){
                    D[x+d]=D[x]+1;
                    Q.push(x+d);
                }
            }
        }else{
            while(P[x]!=0){
                if(D[x+P[x]]>D[x]){
                    D[x+P[x]]=D[x];
                    Q.push(x+P[x]);
                    x+=P[x];
                }else{
                    break;
                }
            }
        }
    }
    cout<<D[N-1]<<endl;
    return 0;
}
