#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, a[maxn], m;
struct P {
  int p, k, idx;
  P() {}
  P(int p, int k, int idx) : p(p), k(k), idx(idx) {}
  bool operator<(const P& a) const { return k < a.k; }
} b[maxn];
int curti;
int mp[maxn], ti[maxn];
int dfs(int cur, int k) {
  if (cur > n) return 0;
  if (ti[cur] == curti) return mp[cur];
  int ret = 1 + dfs(cur + a[cur] + k, k);
  ti[cur] = curti;
  return mp[cur] = ret;
}
int ans[maxn];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cin >> m;
  for (int i = 0; i < m; i++) {
    int p, k;
    cin >> p >> k;
    b[i] = P(p, k, i);
  }
  sort(b, b + m);
  curti = 1;
  for (int i = 0; i < m; i++) {
    if (i && b[i].k != b[i - 1].k) curti++;
    ans[b[i].idx] = dfs(b[i].p, b[i].k);
  }
  for (int i = 0; i < m; i++) cout << ans[i] << endl;
  return 0;
}
