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 used = new bool[N];
    auto next = new int[N]; next[] = -1; next[0] = 0;
    foreach (i; 0 .. N) {
        if (used[i]) continue;
        int[] stack;
        int k = i;
        while (true) {
            stack ~= k;
            if (P[k] == 0) {
                foreach (e; stack) next[e] = k;
                break;
            } else if (used[k]) {
                foreach (e; stack) next[e] = next[k];
                break;
            }
            used[k] = true;
            k = max(0, min(N, k + P[k]));
        }
    }

    DList!S Q;
    Q.insert(S(0, 0));
    used[] = false;
    used[0] = true;
    while (!Q.empty) {
        S c = Q.front; Q.removeFront;
        //writeln(c);
        if (c.x == N - 1) {
            writeln(c.cost);
            return;
        }
        for (int k = 1; k <= 6; k++) {
            int n = max(0, min(N - 1, c.x + k));
            int m = next[n];
            if (m < 0) continue;
            if (used[m]) continue;
            used[m] = true;
            Q.insert(S(m, c.cost + 1));
        }
    }
    assert(0);
}