#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <functional>

constexpr int INF=1<<28;

struct Edge {
  size_t src, dst;
  int cost;
  Edge() {}
  Edge(size_t src, size_t dst, int cost): src(src), dst(dst), cost(cost) {}
};

template <class T>
using iqueue=std::priority_queue<T, std::vector<T>, std::greater<T>>;

std::vector<int> shortest(const std::vector<std::vector<Edge>> &g, size_t s) {
  std::vector<int> d(g.size(), INF);
  d[s] = 0;
  iqueue<std::pair<int, size_t>> q;
  q.emplace(0, s);
  while (!q.empty()) {
    int w=q.top().first;
    size_t v=q.top().second;
    q.pop();
    if (w > d[v])
      continue;
 
    for (const Edge &e: g[v]) {
      if (d[e.dst] > d[e.src] + e.cost) {
	// fprintf(stderr, "src: d[%zu] = %d\n", e.src, d[e.src]);
	// fprintf(stderr, "dst: d[%zu] = %d\n", e.dst, d[e.dst]);
	d[e.dst] = d[e.src] + e.cost;
	q.emplace(d[e.dst], e.dst);
      }
    }
  }

  return d;
}

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

  std::vector<std::vector<Edge>> g(N);
  for (int i=0; i<N; ++i) {
    int p;
    scanf("%d", &p);
    if (p) {
      // fprintf(stderr, "%d -> %d\n", i, i+p);
      g[i].emplace_back(i, i+p, 0);
    } else {
      for (int j=1; j<=6; ++j) {
	if (i+j > N-1)
	  continue;

	// fprintf(stderr, "%d -> %d\n", i, i+j);
	g[i].emplace_back(i, i+j, 1);
      }
    }
  }

  std::vector<int> d=shortest(g, 0);
  // for (int i=0; i<N; ++i)
  //   fprintf(stderr, "%d%c", d[i], i+1<N? ' ':'\n');

  printf("%d\n", d.back());
  return 0;
}