#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
const i64 MOD = 1e9+7;
const i64 INF = 1e18+7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& x : a)
        cin >> x;
    vector<int> pos;
    for(int i = 0; i < n; ++i)
        if(a[i] == 0)
            pos.emplace_back(i);
    vector<int> group(n, -1);
    vector<vector<int>> rev(n);
    for(int i = 0; i < n; ++i)
        if(a[i])
            rev[i + a[i]].emplace_back(i);

    function<void(int,int)> f = [&](int x, int idx){
        for(auto& y : rev[x]){
            if(group[y] == -1){
                group[y] = idx;
                f(y, idx);
            }
        }
    };

    for(int i = 0; i < pos.size(); ++i){
        int val = pos[i];
        group[val] = i;
        f(val, i);
    }
    int m = pos.size();
    vector<vector<int>> edges(m);
    for(int i = 0; i < m; ++i){
        for(int j = 1; j <= 6; ++j)
            if(pos[i] + j < n && group[pos[i] + j] != -1){
                edges[i].emplace_back(group[pos[i] + j]);
            }
    }
    queue<int> que;
    vector<int> range(m, MOD);
    range[0] = 0;
    que.emplace(0);
    while(!que.empty()){
        int to = que.front();
        que.pop();
        for(auto& x : edges[to])
            if(chmin(range[x], range[to] + 1)){
                que.emplace(x);
            }
    }
    cout << range.back() << endl;
}


signed main(){
    solve();
}

