#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

struct edge{
    int to;
    int cost;
};

const int MAX_N = 100010;

int a[MAX_N];
int n;
int d[MAX_N];
vector<edge> G[MAX_N];

void dijkstra(int s)
{
	priority_queue<P,vector<P>,greater<P> > que;
	d[s] = 0;
	que.push(P(0,s));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		vector<edge>::iterator it = G[v].begin();
		rep(i,G[v].size()){
			if(d[G[v][i].to] > d[v] + G[v][i].cost){
				d[G[v][i].to] = d[v] + G[v][i].cost;
				que.push(P(d[G[v][i].to],G[v][i].to));
			}
		}
	}
}

int main()
{
	scanf("%d",&n);
	rep(i,n){
		scanf("%d",&a[i]);
        if(a[i] == 0){
            rep(j,6){
                G[i].push_back((edge){i+j+1,1});
            }
        }else{
            G[i].push_back((edge){i+a[i],0});
        }
	}
    rep(i,n+6){
        d[i] = INF;
    }
    dijkstra(0);
    int mn = INF;
    rep(i,5){
        mn = min(mn,d[n-1+i]);
    }
    printf("%d\n",mn);
	return 0;
}