#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

const int INF=1000000000;

int n;
int p[100001];
bool passed[100001];
int to[100001];

int dfs(int s){
	passed[s]=true;
	// goal
	if(p[s]==0)return to[s]=s;
	int a=p[s]+s;
	//if(p[a]==0)return to[s]=a;
	// ·ÅÉn_ª©Â©ÁÄ¢é
	if(to[a]!=-1)return to[s]=to[a];
	if(passed[a])return to[s]=INF;
	return to[s]=dfs(a);
}

int bfs(){
	int cnt=1;
	memset(passed,0,sizeof(passed));
	queue<int> q[2];
	int cur=0;
	int nxt=1;
	q[cur].push(0);
	passed[0]=true;
	while(q[cur].size()){
		while(q[cur].size()){
			int cp=q[cur].front();
			q[cur].pop();
			for(int i=1;i<=6;i++){
				int np=i+cp;
				if(np>=n-1)return cnt;
				np=to[np];// npÌê©ç¢¯éê
				if(np==n-1)return cnt;
				if(np!=INF&&!passed[np]){
					passed[np]=true;
					q[nxt].push(np);
				}
			}
		}
		cnt++;
		swap(cur,nxt);
	}
	return INF;
}

int main(){

	cin>>n;
	for(int i=0;i<n;i++)cin>>p[i];
	memset(to,-1,sizeof(to));
	for(int i=0;i<=n;i++){
		if(!passed[i]){
			// Ú®Èµ
			if(p[i]==0){
				passed[i]=true;
				to[i]=i;
			}
			else to[i]=dfs(i);
		}
	}
	int a=to[2];
	// Dæ
	int res=bfs();
	cout<<res<<endl;

	return 0;
}