#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { vector<int> num; int number; while (cin>> number)num.push_back(number); int len = num.size(); int index = 0; int ret = 101; for (int j = 1; j<len / 2; j++) { int cout = 1; index = j; while (index<len - 1) { cout++; index += num[index]; } if (index == len - 1)ret = min(ret, cout); } if (ret>100)cout << -1 << endl; else cout << ret << endl; return 0; }