#include using namespace std; typedef pair PII; const int N = 110; int a[N]; int st[N]; int n; void bfs() { queue q; // first:当前木桩号 sencond:从起点走了几步到达了当前的木桩 q.push({1, 0}); st[1] = 1; while (q.size()) { auto t = q.front(); q.pop(); if (t.first == n) { cout << t.second << endl; exit(0); } for (int i = 1; i <= a[t.first]; i++) { int x = t.first + i; if (st[x]) continue; q.push({x, t.second + 1}); st[x] = 1; } } } int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; bfs(); return 0; }