#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)
int dp[110000];
signed main(){
  int n;
  cin>>n;
  lp(i,110000) dp[i]=INF;
  int a[110000];
  lp(i,n) cin>>a[i];
  queue<pair<int,int> > q;
  int next=0;
  int cnt=0;
  dp[0]=0;
  while(1){
    if(next==n-1){
      cout<<0<<endl;
      return 0;
    }
    dp[next]=cnt;
    if(a[next]==0) break;
    dp[next]=cnt;
    next+=a[next];
  }
  q.push({next,0});
  while(!q.empty()){
    int now=q.front().first;
    cnt=q.front().second;
    q.pop();
    for(int i=1;i<=6;i++){
      next=now+i;
      if(next>=n) break;
      int stat=0;
      if(dp[next]<=cnt+1) continue;
      dp[next]=cnt+1;
      while(1){
	if(a[next]==0) break;
	next+=a[next];
	if(dp[next]<=cnt+1){
	  stat=1;
	  break;
	}
	dp[next]=cnt+1;
      }
      if(stat==1) continue;
      
      q.push({next,cnt+1});
    }
  }
  /*lp(i,n) cout<<dp[i]<<" ";
    cout<<endl;*/
  cout<<dp[n-1]<<endl;
  return 0;
}


