#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

const int INF = 1000000005;
int N, p[100005], dp[100005];

void dfs(int prevPos, int currentPos, int step){
  if(dp[currentPos] <= step) return;
  dp[currentPos] = step;
  if(currentPos == N-1) return;
  if(p[currentPos] > 0) dfs(currentPos, min(N - 1, currentPos + p[currentPos]), step);
  else if(p[currentPos] < 0) dfs(currentPos, max(0, currentPos + p[currentPos]), step);
  else{
    REP(i,1,7){
      dfs(currentPos, min(N-1, currentPos+i), step+1);
    }
  }
  return;
}

int main() {
  cin>>N;
  REP(i,0,N) cin>>p[i];
  REP(i,0,N) dp[i] = INF;
  dfs(-1,0,0);
  cout<<dp[N-1]<<endl;
  return 0;
}