#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int p[100000];
int dist[100000];

int main() {
  int n;
  cin >> n;
  REP(i,n) cin >> p[i];
  priority_queue<pii> Q;
  Q.push(pii(0,0));
  REP(i,n)dist[i]=INF;
  dist[0] = 0;
  while(!Q.empty()) {
    pii q = Q.top(); Q.pop();
    int d = -q.first;
    int now = q.second;

    //cout << now << " " << d << endl;
    
    if (p[now]) {
      int nn = now+p[now];
      if (dist[nn] > d) {
        dist[nn] = d;
        Q.push(pii(-d, nn));
      }
    } else {
      for (int i=1; i<=6; ++i) {
        int nn = now+i;
        if (nn>n) break;
        if (dist[nn] > d+1) {
          //cout << now << " ; " << i << endl;
          dist[nn] = d+1;
          Q.push(pii(-(d+1),now+i));
        }
      }
    }
  }
  cout << dist[n-1] << endl;
}