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.


//@author->.....future_me......//

//..............Learning.........//

import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.BigInteger;

public class B {

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Starts <<<<<<<<<<<<<<<<<<<<<<<<<<<<< //
  static FastReader  sc     = new FastReader();
  static PrintWriter out    = new PrintWriter(System.out);
  static int         ubound = (int) 1e9;
  static int         lbound = -(int) 1e9;

  public static void main(String[] args) throws Exception {
//    try {
//    int t = sc.nextInt();
//    while (t-- > 0)
    B.go();
    out.flush();
//    } catch (Exception e) {
//      return;
//    }
  }

  static void go() throws Exception {
    int n = sc.nextInt();
    int a[] = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    int dp[][] = new int[(int) Math.sqrt(100000) + 5][100005];
    for (int i = 1; i <= Math.sqrt(n); i++) {
      for (int j = n; j >= 1; j--) {
        int x = j + a[j - 1] + i;
        if (x > n) {
          dp[i][j] = 1;
        } else {
          dp[i][j] = dp[i][x] + 1;
        }
      }

    }
    int q = sc.nextInt();
    for (int i = 0; i < q; i++) {
      int p = sc.nextInt();
      int k = sc.nextInt();
      if (p > n) {
        System.out.println(0);
        continue;
      }
      int sum = p + a[p - 1] + k;

      if (sum > n) {
        System.out.println(1);
      } else {
        if (1l * k * k >= n) {
          int count = 1;
          while (sum <= n) {
            sum += a[sum - 1] + k;
            count++;
          }
          System.out.println(count);
        } else {
          System.out.println(dp[k][p]);
        }
      }

    }
  }

  /*
   * 5 16 9 8 7 7 1
   */

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Code Ends <<<<<<<<<<<<<<<<<<<<<<<<<<<<< //

  static void reverse(int a[]) {
    ArrayList<Integer> aa = new ArrayList<>();
    sort(a);
    for (int i : a) {
      aa.add(i);
    }
    Collections.reverse(aa);
    for (int i = 0; i < a.length; i++) {
      a[i] = aa.get(i);
    }
  }

  static int gcd(int a, int b) {
    if (b == 0) {
      return a;
    }
    return gcd(b, a % b);

  }

  private static void sort(int[] a) {
    ArrayList<Integer> aa = new ArrayList<>();
    for (Integer i : a) {
      aa.add(i);
    }
    Collections.sort(aa);
    for (int i = 0; i < a.length; i++)
      a[i] = aa.get(i);

  }

  static void sort(long[] a) {
    ArrayList<Long> aa = new ArrayList<>();
    for (Long i : a) {
      aa.add(i);
    }
    Collections.sort(aa);
    for (int i = 0; i < a.length; i++)
      a[i] = aa.get(i);
  }

  static int mod = 3;

  static long pow(long x, long y) {
    long res = 1l;
    while (y != 0) {
      if (y % 2 == 1) {
        res = (x * res);

      }
      y /= 2;
      x = (x * x);
    }
    return res;
  }

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Fast IO <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //

  static class FastReader {
    BufferedReader  br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }

}

//class con {
//  int x, y;
//
//  con(int x, int y) {
//    this.x = x;
//    this.y = y;
//  }
//}
