#include <bits/stdc++.h>
#pragma pack(1)
#pragma GCC optimize("O3")
using namespace std;
const int inf = 1000000000;
const long long INF = 1LL * inf * inf;
const long double eps = 1e-9;
const long long md = 1e9 + 7;
const long double EPS = 1e-5;
const long long maxll = std::numeric_limits<long long>::max();
const long double PI = acos(-1.0);
template <typename name>
inline name sqr(name x) {
  return x * x;
}
long double log(long double base, long double n) { return log(n) / log(base); }
inline long long multmod(long long a, long long b, long long md) {
  if (!a) return 0;
  if (a % 2 == 1)
    return (multmod(a - 1, b, md) + b) % md;
  else
    return sqr(multmod(a / 2, b, md)) % md;
}
template <typename name>
inline name bpow(const name& base, long long exp, const long long& md = maxll) {
  if (exp == 1) return base;
  if (exp % 2 == 1)
    return (bpow<name>(base, exp - 1, md) * base) % md;
  else {
    name k = bpow<name>(base, exp / 2, md);
    return (k * k) % md;
  }
}
unsigned char ccc;
inline void read(int& n) {
  n = 0;
  bool _minus = false;
  while (true) {
    ccc = getchar();
    if (ccc == ' ' || ccc == '\n') break;
    if (ccc == '-') {
      _minus = true;
      continue;
    }
    n = n * 10 + ccc - '0';
  }
  if (_minus) n *= -1;
}
inline void read(int& n, int& m) {
  read(n);
  read(m);
}
inline void read(int& n, int& m, int& k) {
  read(n);
  read(m);
  read(k);
}
inline void read(std::string& s) {
  s = "";
  while (true) {
    ccc = getchar();
    if (ccc == ' ' || ccc == '\n') break;
    s += ccc;
  }
}
template <typename T1, typename T2>
inline T1 min(const T1 x, const T2 y) {
  return (x > y ? y : x);
}
template <typename T1, typename T2>
inline T1 max(const T1 x, const T2 y) {
  return (x < y ? y : x);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& rhs) {
  os << rhs.first << " " << rhs.second;
  return os;
}
const int MAXN = 1e5 + 20;
const int SZ = 250;
int dp[MAXN][SZ], n, a[MAXN], q;
int main() {
  (("" != "") ? freopen(""
                        ".in",
                        "r", stdin),
   freopen(""
           ".out",
           "w", stdout)
              : 0);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = n; i >= 1; i--)
    for (int j = 1; j < SZ; j++) {
      if (i + a[i] + j > n)
        dp[i][j] = 1;
      else
        dp[i][j] = dp[i + a[i] + j][j] + 1;
    }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int p, k;
    scanf("%d%d", &p, &k);
    if (k < SZ) {
      cout << dp[p][k] << "\n";
    } else {
      int ans = 0;
      while (p <= n) {
        p = p + a[p] + k;
        ans++;
      }
      cout << ans << "\n";
    }
  }
}

### Prompt

Please formulate 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>
#pragma pack(1)
#pragma GCC optimize("O3")
using namespace std;
const int inf = 1000000000;
const long long INF = 1LL * inf * inf;
const long double eps = 1e-9;
const long long md = 1e9 + 7;
const long double EPS = 1e-5;
const long long maxll = std::numeric_limits<long long>::max();
const long double PI = acos(-1.0);
template <typename name>
inline name sqr(name x) {
  return x * x;
}
long double log(long double base, long double n) { return log(n) / log(base); }
inline long long multmod(long long a, long long b, long long md) {
  if (!a) return 0;
  if (a % 2 == 1)
    return (multmod(a - 1, b, md) + b) % md;
  else
    return sqr(multmod(a / 2, b, md)) % md;
}
template <typename name>
inline name bpow(const name& base, long long exp, const long long& md = maxll) {
  if (exp == 1) return base;
  if (exp % 2 == 1)
    return (bpow<name>(base, exp - 1, md) * base) % md;
  else {
    name k = bpow<name>(base, exp / 2, md);
    return (k * k) % md;
  }
}
unsigned char ccc;
inline void read(int& n) {
  n = 0;
  bool _minus = false;
  while (true) {
    ccc = getchar();
    if (ccc == ' ' || ccc == '\n') break;
    if (ccc == '-') {
      _minus = true;
      continue;
    }
    n = n * 10 + ccc - '0';
  }
  if (_minus) n *= -1;
}
inline void read(int& n, int& m) {
  read(n);
  read(m);
}
inline void read(int& n, int& m, int& k) {
  read(n);
  read(m);
  read(k);
}
inline void read(std::string& s) {
  s = "";
  while (true) {
    ccc = getchar();
    if (ccc == ' ' || ccc == '\n') break;
    s += ccc;
  }
}
template <typename T1, typename T2>
inline T1 min(const T1 x, const T2 y) {
  return (x > y ? y : x);
}
template <typename T1, typename T2>
inline T1 max(const T1 x, const T2 y) {
  return (x < y ? y : x);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& rhs) {
  os << rhs.first << " " << rhs.second;
  return os;
}
const int MAXN = 1e5 + 20;
const int SZ = 250;
int dp[MAXN][SZ], n, a[MAXN], q;
int main() {
  (("" != "") ? freopen(""
                        ".in",
                        "r", stdin),
   freopen(""
           ".out",
           "w", stdout)
              : 0);
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = n; i >= 1; i--)
    for (int j = 1; j < SZ; j++) {
      if (i + a[i] + j > n)
        dp[i][j] = 1;
      else
        dp[i][j] = dp[i + a[i] + j][j] + 1;
    }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int p, k;
    scanf("%d%d", &p, &k);
    if (k < SZ) {
      cout << dp[p][k] << "\n";
    } else {
      int ans = 0;
      while (p <= n) {
        p = p + a[p] + k;
        ans++;
      }
      cout << ans << "\n";
    }
  }
}

```