#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N,p[100010];
int to[100010],vis[100010],dist[100010];

int f(int cur){
	if(to[cur]!=-1)return to[cur];
	if(vis[cur] && to[cur]==-1)return to[cur]=-2;
	vis[cur]=1;
	if(p[cur]==0)return to[cur]=cur;
	return to[cur]=f(cur+p[cur]);
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N;
	rep(i,N)cin>>p[i];
	memset(to,-1,sizeof(to));
	rep(i,N)f(i);
	fill(dist,dist+N,INF);
	dist[0]=0;
	
	queue<int> Q;
	Q.push(0);
	while(sz(Q)){
		int x=Q.front();Q.pop();
		rep2(i,1,7){
			int nx=min(x+i,N-1);
			if(dist[to[nx]]==INF){
				dist[to[nx]]=dist[x]+1;
				Q.push(to[nx]);
			}
		}
	}
	cout<<dist[N-1]<<endl;
}