#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000009;
const int MAXN = 100 * 1000;
const int MAXK = 350;
int n, q;
int a[MAXN + 3];
int M[MAXN + 3][MAXK + 3];
int Query(int p, int k) {
  if (p > n) return 0;
  if (k < MAXK && M[p][k] > 0) return M[p][k];
  int ret = 1 + Query(p + a[p] + k, k);
  if (k < MAXK) M[p][k] = ret;
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  scanf("%d", &q);
  while (q--) {
    int p, k;
    scanf("%d %d", &p, &k);
    printf("%d\n", Query(p, k));
  }
  return 0;
}
