#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
mt19937 rng(steady_clock::now().time_since_epoch().count());
void usaco(string filename) {
  freopen((filename + ".in").c_str(), "r", stdin);
  freopen((filename + ".out").c_str(), "w", stdout);
}
const long long mod = 998244353;
long long madd(long long a, long long b) { return (a + b) % mod; }
long long msub(long long a, long long b) {
  return (((a - b) % mod) + mod) % mod;
}
long long mmul(long long a, long long b) {
  return ((a % mod) * (b % mod)) % mod;
}
long long mpow(long long base, long long exp) {
  long long res = 1;
  while (exp) {
    if (exp % 2 == 1) {
      res = (res * base) % mod;
    }
    exp >>= 1;
    base = (base * base) % mod;
  }
  return res;
}
long long minv(long long base) { return mpow(base, mod - 1); }
long long mdiv(long long a, long long b) { return mmul(a, minv(b)); }
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
bool prime[10000006];
void sieve(int n) {
  for (long long i = 0; i < n + 1; i++) prime[i] = 1;
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  prime[1] = prime[0] = 0;
}
long long n, m, q, Q, T, k, l, r, x, y, z, g;
long long magic = 300;
int a[100005];
int steps[305][100005];
int get(int loc, int k) {
  if (loc >= n) return 0;
  if (steps[k][loc] != -1) return steps[k][loc];
  return steps[k][loc] = 1 + get(loc + a[loc] + k, k);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  cin >> Q;
  for (long long i = 0; i < magic + 1; i++)
    for (long long j = 0; j < n; j++) steps[i][j] = -1;
  for (long long i = 0; i < Q; i++) {
    cin >> m >> k;
    --m;
    if (k <= magic) {
      cout << get(m, k) << '\n';
    } else {
      int stp = 0;
      while (m < n) {
        ++stp;
        m = m + a[m] + k;
      }
      cout << stp << '\n';
    }
  }
}

### Prompt

Your challenge is to write a CPP solution to the following problem:

a is an array of n positive integers, all of which are not greater than n.

You have to process q queries to this array. Each query is represented by two numbers p and k. Several operations are performed in each query; each operation changes p to p + ap + k. There operations are applied until p becomes greater than n. The answer to the query is the number of performed operations.

Input

The first line contains one integer n (1 ≤ n ≤ 100000).

The second line contains n integers — elements of a (1 ≤ ai ≤ n for each i from 1 to n).

The third line containts one integer q (1 ≤ q ≤ 100000).

Then q lines follow. Each line contains the values of p and k for corresponding query (1 ≤ p, k ≤ n).

Output

Print q integers, ith integer must be equal to the answer to ith query.

Example

Input

3
1 1 1
3
1 1
2 1
3 1


Output

2
1
1

Note

Consider first example:

In first query after first operation p = 3, after second operation p = 5.

In next two queries p is greater than n after the first operation.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
mt19937 rng(steady_clock::now().time_since_epoch().count());
void usaco(string filename) {
  freopen((filename + ".in").c_str(), "r", stdin);
  freopen((filename + ".out").c_str(), "w", stdout);
}
const long long mod = 998244353;
long long madd(long long a, long long b) { return (a + b) % mod; }
long long msub(long long a, long long b) {
  return (((a - b) % mod) + mod) % mod;
}
long long mmul(long long a, long long b) {
  return ((a % mod) * (b % mod)) % mod;
}
long long mpow(long long base, long long exp) {
  long long res = 1;
  while (exp) {
    if (exp % 2 == 1) {
      res = (res * base) % mod;
    }
    exp >>= 1;
    base = (base * base) % mod;
  }
  return res;
}
long long minv(long long base) { return mpow(base, mod - 1); }
long long mdiv(long long a, long long b) { return mmul(a, minv(b)); }
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
bool prime[10000006];
void sieve(int n) {
  for (long long i = 0; i < n + 1; i++) prime[i] = 1;
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  prime[1] = prime[0] = 0;
}
long long n, m, q, Q, T, k, l, r, x, y, z, g;
long long magic = 300;
int a[100005];
int steps[305][100005];
int get(int loc, int k) {
  if (loc >= n) return 0;
  if (steps[k][loc] != -1) return steps[k][loc];
  return steps[k][loc] = 1 + get(loc + a[loc] + k, k);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  cin >> Q;
  for (long long i = 0; i < magic + 1; i++)
    for (long long j = 0; j < n; j++) steps[i][j] = -1;
  for (long long i = 0; i < Q; i++) {
    cin >> m >> k;
    --m;
    if (k <= magic) {
      cout << get(m, k) << '\n';
    } else {
      int stp = 0;
      while (m < n) {
        ++stp;
        m = m + a[m] + k;
      }
      cout << stp << '\n';
    }
  }
}

```