#include #define endl '\n' #define TRACE(x) cerr << #x << " = " << x << endl using namespace std; template inline bool chkmax(T &x, const T1 &y) { return x < y ? x = y, true : false; } template inline bool chkmin(T &x, const T1 &y) { return x > y ? x = y, true : false; } const bool ONPC = false; const int MAXN = (int)1e5 + 1; int n; int a[MAXN]; int q; pair queries[MAXN]; void read() { if (!ONPC) { freopen("jumps.in", "rt", stdin); freopen("jumps.out", "wt", stdout); } cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; cin >> q; for (int i = 1; i <= q; i++) cin >> queries[i].first >> queries[i].second; } void solve() { for (int i = 1; i <= q; i++) { int jumps = 0; int pos = queries[i].first; while (true) { jumps++; int to = pos + a[pos]; if (queries[i].second <= to) break; pos = to; } cout << jumps << endl; } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); read(); solve(); return EXIT_SUCCESS; }