#include <iostream>
#include <vector>
#include <queue>
#define inf 1000000000

using namespace std;

int n;
int p[100005];
int to[100005];
bool used[100005];
vector<int> G[100005];
int dist[100005];

int dfs(int v)
{
	used[v] = true;
	int u = v + p[v];
	
	if(p[v] == 0) to[v] = v;
	else if(used[u])to[v] = inf;
	else if(to[u] != 0) to[v] = to[u];
	else to[v] = dfs(u);
	
	used[v] = false;
	return to[v];
}

void bfs()
{
	for(int i = 1; i <= n; i++) dist[i] = inf;
	dist[1] = 0;
	
	queue<int> Q;
	Q.push(1);
	int v;
	while(Q.size()){
		v = Q.front();
		Q.pop();
		for(int i = 0; i < G[v].size(); i++){
			if(dist[G[v][i]] < inf) continue;
			dist[G[v][i]] = dist[v] + 1;
			Q.push(G[v][i]);
		}
	}
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> p[i];
	
	for(int i = 1; i <= n; i++) if(to[i] == 0) to[i] = dfs(i);
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= 6; j++){
			int v = min(i+j, n);
			if(to[v] == inf) continue;
			G[i].push_back(to[v]);
		}
	}
	
	bfs();
	cout << dist[n] << endl;
	
	return 0;
}
