#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005
int N;
int p[MAX_N];
int visited[MAX_N];
int main(){
  
  cin>>N;
  for(int i=1;i<=N;i++){
    cin>>p[i];
    visited[i]=-1;
  }
  queue<int> Q;
  Q.push(1);
  visited[1]=0;
  
  while(!Q.empty()){
    int pos=Q.front();Q.pop();
    for(int i=1;i<=6;i++){
      int to=pos+i;
      if(to>N)continue;
      while(visited[to]==-1&&p[to]!=0){
	visited[to]=visited[pos]+1;
	to+=p[to];
      }
      if(visited[to]!=-1)continue;
      visited[to]=visited[pos]+1;
      Q.push(to);
    }
  }
  
  cout<<visited[N]<<endl;

  return 0;
}