#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<(int)N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
typedef long long ll;
using namespace std;
const int inf=1e9;
 
 
int main(){
    int n;
    cin>>n;
    int dp[100010];//no-visit inf, NG -inf,
    int effect[100010];
    REP(i,0,n) cin>>effect[i];
    REP(i,0,n) dp[i]=inf;
    queue<int> q;
    dp[0]=0;
    q.push(0);
    //bfs
    while(!q.empty()){
        int now=q.front();q.pop();
        REP(i,1,7){
            int next=now+i;
            if(next>n-1) break;
            if(dp[next]==inf){
                set<int> s;//check
                while(1){
                    s.insert(next);
                    next+=effect[next];
                    if(effect[next]==0){
                        s.insert(next);
                        for(auto itr=s.begin();itr!=s.end();itr++) {
                            dp[*itr]=min(dp[*itr],dp[now]+1);
                        }
                        q.push(next);
                        break;
                    }
                    if(s.find(next)!=s.end()||dp[next]!=inf){
                        for(auto itr=s.begin();itr!=s.end();itr++) dp[*itr]=inf-1;
                        break;
                    }
                }
            }
        }
        if(dp[n-1]<inf-1){
            break;
        }
    }
    p(dp[n-1]);
    return 0;
}