#include<bits/stdc++.h>
using namespace std;

const int SIZE=100010;
const int INF=1e9;

int N,p[SIZE];
int to[SIZE],dist[SIZE];
bool used[SIZE];

int dfs(int v){
  if(p[v]==0) return v;
  used[v]=true;
  if(used[v+p[v]]){
    if(to[v+p[v]]==v+p[v]) return to[v]=-1;
    else return to[v]=to[v+p[v]];
  }
  return to[v]=dfs(v+p[v]);
}

void solve(){
  vector<int> dist(N+1);
  for(int i=1;i<=N;i++) dist[i]=INF;
  dist[1]=0;
  queue<int> Q;
  Q.push(1);

  while(!Q.empty()){
    int cur=Q.front(); Q.pop();
    for(int d=1;d<=6;d++){
      int nxt=cur+d;
      if(nxt>=N){
	if(dist[N]==INF) dist[N]=dist[cur]+1;
	cout<<dist[N]<<endl;
	return;
      }
      nxt=to[nxt];
      if(nxt==-1) continue;
      if(dist[nxt]==INF){
	dist[nxt]=dist[cur]+1;
	Q.push(nxt);
      }
    }
  }
  cout<<dist[N]<<endl;
}

int main(){
  cin>>N;
  for(int i=1;i<=N;i++) cin>>p[i]; //1-indexed

  for(int i=1;i<=N;i++) to[i]=i;
  for(int i=1;i<=N;i++){
    if(p[i]!=0 and to[i]==i) dfs(i);
  }
  solve();
}
  
  

