#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <climits>
#include <set>
using namespace std;
#define repn(i,s,n) for (int i=int(s); i < int(n); i++)
#define rep(i,n) repn(i,0,n)
#define repd(i,n) for (int i=int(n)-1; i >= 0; i--)

typedef vector<int> VI;


int main() {
  int n;
  cin >> n;
  VI ps(n);
  rep(i,n) cin >> ps[i];

  VI state(n);  // 0: undefined, 1: traversing, 2:fixed
  VI dest(n);   // テ」ツδ榲」ツつケiテ」ツ?ォテヲツュツ「テ」ツ?セテ」ツ?」テ」ツ?淌ヲツ卍づ」ツ?ョティツ。ツ古・ツ?暗」ツ??1テ」ツ?ェテ」ツつ嘉ァツ?。テゥツ卍静」ツδォテ」ツδシテ」ツδ療」ツ??

  function<int(int)> dfs = [&](int v) -> int {
    if (ps[v] == 0) {
      // vテ」ツ?古・ツ按ーテァツ敖?・ツ慊ーテ」ツ?ョテ」ツδ榲」ツつケ
      state[v] = 2;
      return dest[v] = v;
    }
    if (state[v] == 2) {
      // vテ」ツ?古・ツ按ーテァツ敖?・ツ慊ーテ」ツ?古」ツ?ゥテ」ツ?禿」ツ?凝ァツ「ツコテ・ツョツ堙」ツ?療」ツ?ヲテ」ツ??」ツつ凝」ツδ榲」ツつケ
      return dest[v];
    }
    if (state[v] == 1) {
      // テァツ?。テゥツ卍静」ツδォテ」ツδシテ」ツδ療ヲツ、ツ愿・ツ?コ
      return -1;
    }
    state[v] = 1;
    dest[v] = dfs(v + ps[v]);  // テ・ツ?暗」ツ?クテゥツ?イテ」ツつ禿」ツ?ァテァツ「ツコテ・ツョツ堙」ツ?陛」ツ?崚」ツつ?
    state[v] = 2;
    return dest[v];
  };
  rep(i, n) {
    if (state[i] == 0) dfs(i);
  }

  // テゥツ鳴凝・ツァツ凝ァツつケテ」ツ?凝」ツつ嘉・ツケツ?・ツ?ェテ・ツ?暗ヲツ篠「テァツエツ「
  queue<int> que;
  que.push(0);
  VI dist(n, -1);
  dist[0] = 0;

  while(!que.empty()) {
    int v = que.front();
    que.pop();
    repn(i, v+1, v+7) {
      if (i >= n) break;
      int d = dest[i];
      if (d == -1) continue;
      if (dist[d] != -1) continue;
      dist[d] = dist[v] + 1;
      que.push(d);
    }
  }

  cout << dist[n-1] << endl;
  return 0;
}