#include <iostream>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

typedef pair<int, int> P;

const int N = 100000;
const int INF = (1<<28);

int n, d[N], vis[N], vis2[N];
bool loop[N];

void find_loop(int p){
  vis[p] = true;
  for(int i=1;i<=6&&p+i<n;i++){
    int np = p + i;
    if(vis[np]) continue;
    if(d[np] != 0){
      fill(vis2, vis2+n, false);
      while(1){
        vis[np] = vis2[np] = true;
        if(d[np] == 0) break;
        np += d[np];
        if(vis2[np]){
          np = p + i;
          while(!loop[np]){
            loop[np] = true;
            np += d[np];
          }
          break;
        }
      }
    }
    if(!loop[np] && d[np] == 0) find_loop(np);
  }
}

int solve(){
  fill(vis, vis+n, INF);
  queue<P> q;
  vis[0] = 0;
  q.push(make_pair(0, 0));
  while(!q.empty()){
    P p = q.front(); q.pop();
    if(p.second == n-1) return p.first;
    for(int i=1;i<=6&&p.second+i<n;i++){
      int np = p.second + i;
      if(loop[np]) continue;
      if(vis[np] > p.first + 1){
        while(1){
          vis[np] = p.first + 1;
          if(d[np] == 0) break;
          np += d[np];
        }
        q.push(make_pair(p.first + 1, np));
      }
    }
  }
  return -1;
}

int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> d[i];
  for(int i=0;i<n;i++) vis[i] = loop[i] = false;
  find_loop(0);
  cout << solve() << endl;
}