#include <bits/stdc++.h>
int mod = 1e9 + 7;
const int inf = 1e15;
using namespace std;
int cnt = 0;
vector<pair<int, int> > v[100001];
int a[100001], K, n;
pair<int, int> m[100001];
int dfs(int s) {
  if (s > n) return 0;
  if (m[s].second == K) return m[s].first;
  int ans = dfs(s + a[s] + K) + 1;
  m[s] = {ans, K};
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n + 1; i++) scanf("%d", &a[i]);
  int Q;
  scanf("%d", &Q);
  for (int i = 1; i < Q + 1; i++) {
    int p, k;
    scanf("%d %d", &p, &k);
    v[k].push_back({p, i});
  }
  for (int i = 1; i < 100001; i++) sort(v[i].begin(), v[i].end());
  for (int i = 1; i < 100001; i++) m[i] = {0, 0};
  int res[Q + 1];
  for (int i = 1; i < 100001; i++) {
    K = i;
    for (pair<int, int> j : v[i]) {
      if (m[j.first].second == i)
        res[j.second] = m[j.first].first;
      else
        res[j.second] = dfs(j.first);
      if (cnt > 6e7) return -1;
    }
  }
  for (int i = 1; i < Q + 1; i++) printf("%d ", res[i]);
}
