#include<cstdio>
#include<queue>
#include<map>
#include<functional>
using namespace std;
typedef pair<int,int>S;
int main()
{
	int N,p[100000],i,j,c;
	for(i=!scanf("%d",&N);i<N;++i)scanf("%d",p+i);
	bool f[100000]={};
	priority_queue<S,vector<S>,greater<S> >q;
	q.push(S(0,0));
	for(;;)
	{
		S s=q.top();q.pop();
		c=s.first;
		i=s.second;
		if(f[i]++)continue;
		if(i>=N-1)break;
		if(p[i])q.push(S(c,i+p[i]));
		else for(j=1;j<7;++j)q.push(S(c+1,i+j));
	}
	return !printf("%d\n",c);
}