import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

struct S {
    int x, cost;
}


void main() {
    int N; scanf("%d\n", &N);
    int[] P = new int[N];
    foreach (i; 0 .. N) {
        scanf("%d\n", &P[i]);
    }

    auto next = new int[N];
    auto used = new bool[N];
    void init() {
        next[] = -1;
        foreach (i; 0 .. N) {
            if (P[i] == 0) {
                next[i] = i;
            } else if (i + P[i] >= N - 1) {
                next[i] = N - 1;
            } else if (next[i + P[i]] >= 0) {
                next[i] = next[i + P[i]];
            } else {
                int k = i;
                used[] = false;
                while (true) {
                    if (used[k]) { // loop
                        foreach (a; 0 .. N) if (used[a]) next[a] = -3;
                        break;
                    }
                    if (next[k] >= 0) {
                        foreach (a; 0 .. N) if (used[a]) next[a] = next[k];
                        break;
                    }
                    used[k] = true;
                    if (P[k] == 0) {
                        foreach (a; 0 .. N) if (used[a]) next[a] = k;
                        break;
                    }
                    k = k + P[k];
                }
            }
        }
        int dfs(int index) {
            if (next[index] >= 0) return next[index];
            if (P[index] == 0) return next[index] = index;
            if (next[index] == -2 || next[index] == -3) return -3;
            next[index] = -2;
            next[index] = dfs(index + P[index]);
            return next[index];
        }
        foreach (i; 0 .. N) dfs(i);
    }
    init;

    DList!S Q;
    Q.insert(S(0, 0));
    while (!Q.empty) {
        auto c = Q.front; Q.removeFront;
        if (c.x >= N - 1) {
            writeln(c.cost);
            break;
        }
        foreach (k; 1 .. 7) {
            S n;
            n.cost = c.cost + 1;
            if (c.x + k >= N - 1) {
                n.x = N - 1;
            } else {
                n.x = next[c.x + k];
            }
            if (n.x < 0) continue;
            if (n.x >= N - 1) n.x = N - 1;
            if (used[n.x]) continue;
            used[n.x] = true;
            Q.insert(n);
        }
    }
}