#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {

  long long int n, input;
  cin >> n;

  vector< long long int > map, flag;
  flag.push_back( 0 );
  for ( long long int i = 0; i < n; i++ ) {
    cin >> input;
    map.push_back( input );
    flag.push_back( n+1 );
  }

  queue< long long int > q;
  q.push( 0 );

  while( q.size() > 0 ) {

    long long int k = q.front();
    q.pop();

    if ( map[k] == 0 ) {
      for ( long long int i = 1; i <= 6; i++ ) {
	long long int l = k + i;
	if ( l >= n ) break;
	if ( flag[l] > flag[k]+1 ) {
	  flag[l] = flag[k]+1;
	  q.push( l );
	}
      }

    }else {

      long long int l = k + map[k];
      if ( flag[l] > flag[k] ) {
	flag[l] = flag[k];
	q.push( l );
      }
    }

  }

  cout << flag[n-1] << endl;

  return 0;

}