// Slower C++ solution:
#include <cstdio>

#include <vector>

#include <queue>

#include <algorithm>

#include <utility>

#include <cstring>

using namespace std;



int N, to[100010], dist[100010];

typedef pair<int, int> pii;

const int INF = 1 << 25;



struct UnionFind {

    int node[100010], edge_cnt[100010];

    UnionFind() {

        memset(node, -1, sizeof(node));

        memset(edge_cnt, 0, sizeof(edge_cnt));

    }

    int find(int x) {return node[x] < 0 ? x : node[x] = find(node[x]);}

    int size(int x) {return -node[find(x)];}

    void unite(int x, int y) {

        x = find(x), y = find(y);

        if(size(x) > size(y)) swap(x, y);

        edge_cnt[y]++;

        if(x == y) return;



        // x を y に統合

        node[y] += node[x];

        node[x] = y;

        edge_cnt[y] += edge_cnt[x];

    }

    int edge(int x) {return edge_cnt[find(x)];}

};



UnionFind uf;

int main() {

    scanf("%d", &N);

    for(int i=0; i<N; i++) {

        scanf("%d", &to[i]);

        if(to[i] != 0) uf.unite(i, i+to[i]);

    }

    for(int i=0; i<N; i++) {

        dist[i] = INF;

        if(uf.size(i) <= uf.edge(i)) {

            to[i] = INF;

        }

        // printf("operate: %d, size = %d\n", to[i], uf.size(i));

    }



    dist[0] = 0;

    priority_queue< pii, vector<pii>, greater<pii> > que;

    que.push(make_pair(0, 0));



    while(que.size()) {

        pii cur = que.top(); que.pop();

        int pos = cur.second, cost = cur.first;



        if(pos == N-1) {

            printf("%d\n", dist[pos]);

            return 0;

        }



        if(to[pos] == 0) {

            for(int k=1; k<=6; k++) {

                int npos = min(pos + k, N-1);

                if(to[npos] == INF) continue;

                if(dist[npos] > dist[pos] + 1) {

                    dist[npos] = dist[pos] + 1;

                    que.push(make_pair(dist[npos], npos));

                }

            }

        }

        else {

            int npos = to[pos] + pos;

            if(dist[npos] > dist[pos]) {

                dist[npos] = dist[pos];

                que.push(make_pair(dist[npos], npos));

            }

        }

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.7272249584802395x):
// #define _GLIBCXX_DEBUG // for STL debug (optional)

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <string>

#include <cstring>

#include <deque>

#include <list>

#include <queue>

#include <stack>

#include <vector>

#include <utility>

#include <algorithm>

#include <map>

#include <set>

#include <complex>

#include <cmath>

#include <limits>

#include <cfloat>

#include <climits>

#include <ctime>

#include <cassert>

#include <numeric>

#include <fstream>

#include <functional>

#include <bitset>

using namespace std;

using ll = long long int;

using int64 = long long int;

 

template<typename T> void chmax(T &a, T b) {a = max(a, b);}

template<typename T> void chmin(T &a, T b) {a = min(a, b);}

template<typename T> void chadd(T &a, T b) {a = a + b;}

 

int dx[] = {0, 0, 1, -1};

int dy[] = {1, -1, 0, 0};

const int INF = 1LL << 29;

const ll LONGINF = 1LL << 60;

const ll MOD = 1000000007LL;



struct Elem {

    int pos, cost;

    Elem(int p, int c) : pos(p), cost(c) {}

    bool operator<(const Elem &e) const {

        return cost > e.cost;

    }

};



int dist[100010];

int main() {

    int N; scanf("%d", &N);

    vector<int> P(N), dead(N+1), visited(N+1, -1);

    for(int i=0; i<N; i++) {

        scanf("%d", &P[i]);

    }



    // fprintf(stderr, "input end\n");

    for(int i=0; i<N; i++) {

        if(dead[i] or visited[i] >= 0) continue;

        bool ng = false;

        {

            int v = i;

            while(true) {

                visited[v] = i;

                if(P[v] == 0) break;

                v += P[v];

                if(visited[v] == i or dead[v]) {

                    ng = true;

                    break;

                }

            }

        }



        if(ng) {

            int v = i;

            while(true) {

                dead[v] = true;

                v += P[v];

                if(dead[v]) break;

            }

        }

    }



    priority_queue<Elem> que;

    fill(dist, dist + N + 1, INF);

    dist[0] = 0;

    que.emplace(0, 0);

    while(que.size()) {

        auto e = que.top(); que.pop();

        int u = e.pos, c = e.cost;

        if(dist[u] < c or u == N - 1) continue;

        for(int d=1; d<=6 and P[u] == 0; d++) {

            int v = min(u + d, N - 1);

            if(dead[v]) continue;

            if(dist[v] > dist[u] + 1) {

                dist[v] = dist[u] + 1;

                que.emplace(v, dist[v]);

            }

        }

        if(u > 0 or P[u] != 0) {

            int v = u + P[u];

            if(dead[v]) continue;

            if(dist[v] > dist[u]) {

                dist[v] = dist[u];

                que.emplace(v, dist[v]);

            }

        }

    }

    /*

    for(int i=0; i<N; i++) cerr << dead[i] << " ";

    cerr << endl;

    for(int i=0; i<N; i++) cerr << dist[i] << " ";

    cerr << endl;

    */

    printf("%d\n", dist[N - 1]);

    return 0;

}