#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i, 0, n)

const int INF = INT_MAX/10;

struct state {
    int p, t;
	state(int p, int t) : p(p), t(t) {};
    bool operator< (const state &o)const {
        return t>o.t;
	}
};

int main() {
    int N;
    cin >> N;

    vi field(N);
    REP(i, N) {
        cin >> field[i];
	}

    vi turn(N, INF);
    priority_queue<state> Q;

    FOR(i, 1, min(N, 6)+1) {
        Q.push(state(i, 1));
        turn[i] = 1;
	}
    Q.push(state(0, 0));
    turn[0] = 0;

	while(!Q.empty()) {
		state st = Q.top();
		Q.pop();

        if(st.p == N-1) {
            cout << st.t << endl;
            return 0;
		}

        if(field[st.p] != 0) {
            int np = st.p + field[st.p];
            if(np >= N) {
                np = N-1;
			}
            if(turn[np] > st.t) {
                turn[np] = st.t;
                Q.push(state(np, st.t));
			}
		} else {
            FOR(d, 1, 6+1) {
                int np = st.p + d;
                if(np >= N) {
                    np = N-1;
				}
                if(turn[np] > st.t+1) {
                    turn[np] = st.t+1;
                    Q.push(state(np, st.t+1));
				}
			}
		}
	}
}