#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)
#define INF INT_MAX/2

int main()
{
	int n; cin >> n;
	vector<int> p(n);
	rep(i, 0, n) cin >> p[i];

	vector<int> dp(n, INF);
	dp[0] = 0;
	rep(i, 0, n - 1)
	{
		if (p[i] == 0)
		{
			rep(j, 1, 7)
			{
				int next = i + j;
				if (next < n) dp[next] = min(dp[next], dp[i] + 1);
			}
		}
		else
		{
			if (p[i] < 0)
			{
				if (dp[i] < dp[i + p[i]])
				{
					dp[i + p[i]] = dp[i];
					i = i + p[i];
					i--;
					continue;
				}
			}
			else
			{
				dp[i + p[i]] = min(dp[i + p[i]], dp[i]);
			}
		}
	}
	cout << dp[n - 1] << endl;
}