#include <cstdio>
#include <algorithm>
using namespace std;

int n;
int p[100000];
int dp[100006];

void dfs(int i, int t)
{
    if (t >= dp[i])
        return;
    if (i >= n)
        return;

    dp[i] = min(dp[i], t);

    if (p[i] == 0) {
        for (int j = 1; j <= 6; ++j) {
            dfs(i + j, t + 1);
        }
    } else {
        dfs(i + p[i], t);
    }
}

int main()
{
    scanf("%d", &n);

    for (int i = 0; i < n; ++i)
        scanf("%d", &p[i]);

    fill(dp, dp + 100006, 10000000);
    dfs(0, 0);
    printf("%d\n", dp[n - 1]);

    return 0;
}