#include <bits/stdc++.h> using namespace std;
const int N = 100000 + 10; int dep[N]; int d[N]; queueque; int main() { int n; cin >> n; for (int i=1; i<=n; i++) cin >> d[i]; memset(dep,-1,sizeof(dep)); dep[n] = 0; que.push(n); while(!que.empty()) { int x=que.front(),nx; que.pop(); nx=x+d[x]; if(nx<=n&&dep[nx]==-1){ dep[nx]=dep[x]+1; que.push(nx); } nx = x - d[x]; if(nx>=1&&dep[nx]==-1){ dep[nx]=dep[x]+1; que.push(nx); } } cout << dep[1]; return 0; }