#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n, a[100000], to[100000], s[100000], m;
bool v[100000];

int rec(int c){
	if(to[c] >= 0) return to[c];
	if(a[c] == 0) return to[c] = c;
	if(v[c]){
		rep(i, m) to[s[i]] = -1;
		return to[c] = -1;
	}
	s[m++] = c;
	v[c] = 1;
	return to[c] = rec(c + a[c]);
}
int main()
{
	cin >> n;
	rep(i, n) cin >> a[i], to[i] = -1;
	rep(i, n) if(to[i] < 0){
		m = 0;
		rec(i);
	}
	
	queue<pi> q;
	q.push(mp(0, 0));
	memset(v, 0, sizeof(v));
	while(!q.empty()){
		int c = q.front().second;
		int cost = q.front().first; q.pop();
		
		if(v[c]) continue;
		if(c >= n - 7){
			cout << cost + (c != n-1) << endl;
			break;
		}
		v[c] = 1;
		for(int i = 1; i <= 6; i++) if(to[c + i] >= 0 && !v[to[c+i]]){
			q.push(mp(cost + 1, to[c + i]));
		}
	}
	
	return 0;
}