#include <stdio.h>
#include <queue>
#include <iostream>
#define INF 0x7FFFFFFF;

using namespace std;

int main(void){
	int n, p[100000], s[100000], i, d, x;
	queue<int> que;
	scanf("%d",&n);
	for(i = 0;i < n;i++)
		s[i] = INF;
	for(i = 0;i < n;i++)
		scanf("%d",&p[i]);
	s[0] = 0;
	que.push(0);
	while(que.size()){
		for(i = 1;i <= 6;i++){
			x = que.front() + i, d = s[que.front()] + 1;
			if(x > n - 1)
				x = n - 1;
			else if(x < 0)
				x = 0;
			while(p[x] != 0 && s[x] > d){
				s[x] = d;
				x += p[x];
				if(x > n - 1)
					x = n - 1;
				else if(x < 0)
					x = 0;
			}
			if(p[x] == 0 && s[x] > d){
				que.push(x);
				s[x] = d;
			}
		}
		que.pop();
	}
	printf("%d\n",s[n - 1]);
	return 0;
}