#include <bits/stdc++.h>
using namespace std;

const int INF = 1 << 29;

struct state {
    int pos;
    int time;

    state(int a, int b):
        pos(a), time(b) {}

    bool operator < (const state& o) const {
        return time == o.time ? pos > o.pos : time > o.time;
    }
};

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

    vector<int> p(N);
    vector<int> visited(N, INF);
    visited[0] = 0;

    for (int x = 0; x < N; ++x) {
        cin >> p[x];
    }

    priority_queue<state> que;

    que.push(state(0, 0));
    
    while (!que.empty()) {
        state s = que.top(); que.pop();

        if (s.time > visited[s.pos]) {
            continue;
        }

        if (s.pos >= N-1) {
            break;
        }

        if (p[s.pos] == 0) {
            for (int x = 1; x <= 6; ++x) {
                int nxt = min(s.pos + x, N-1);
                if (s.time + 1 < visited[nxt]) {
                    visited[nxt] = s.time + 1;
                    que.push(state(nxt, s.time + 1));
                }
            }
        } else {
            int nxt = s.pos + p[s.pos];
            if (s.time < visited[nxt]) {
                visited[nxt] = s.time;
                que.push(state(nxt, s.time));
            }
        }
    }

    cout << visited[N-1] << endl;
    return 0;
}