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.
import java.io.*;
import java.util.StringTokenizer;

public class ProblemA {

    public static void solve(InputReader in, PrintWriter out) throws IOException{
        //System.out.println("============");

        int n = in.nextInt();
        int[] a = new int[n];

        for (int i=0; i<n; i++){
            a[i] = in.nextInt();
        }

        int[][] table = genTable(a, n);

        int q = in.nextInt();
        for (int i=0; i<q; i++){
            int p = in.nextInt();
            int k = in.nextInt();

            if (k < Math.sqrt(n)){
                //System.out.println("Table (" + p + ", " + k + ") [" + (k-1) + ", " + (p-1) + "]: " + table[k-1][p-1]);
                //System.out.println("Table[" + (k-1) + "]: " + print(table[k-1]));
                //System.out.println("Array[-]: " + print(a));
                out.println(table[k-1][p-1]);
            } else {
                //System.out.println("Modulation (" + p + ", " + k + "): " + modulation(a, p, k));
                out.println(modulation(a, p, k));
            }
        }
    }

    public static String print(int[] arr){
        String s = "";
        for (int i=0; i<arr.length; i++){
            if (arr[i] < 10) s += " ";
            s += arr[i] + ",";
        }

        return s;
    }

    public static int modulation(int[] a, int p, int k){
        int count = 0;
        //System.out.print(p + ", " + k + ": ");

        while (p <= a.length){
            p = p + a[p-1] + k;
            count++;
        }

        //System.out.println(count);
        return count;
    }

    public static int[][] genTable(int[] a, int n){
        int[][] table = new int[(int) Math.floor(Math.sqrt(n))][n] ;

        for (int i=0; i<table.length; i++){
            for (int j=table[i].length-1; j >= 0; j--){
                int k = i+1;
                int p = j+1;

                if (p + a[p-1] + k >= table[i].length) table[i][j] = modulation(a, p, k);
                else table[i][j] = table[i][p+a[p-1]+k-1]+1;
            }
        }

        return table;
    }

    public static void main(String[] args) throws IOException{
        InputReader in;
        PrintWriter out;

        if (args.length > 0 && args[0].equals("file")) {
            in = new InputReader(new BufferedReader(new FileReader("input.txt")));
            out = new PrintWriter(new FileWriter("output.txt"));

            int sampleNumber = 1;
            do {
                out.println("Sample #" + sampleNumber++ + ": ");
                solve(in, out);
                out.println("");
            } while (in.reader.readLine() != null);
        } else {
            in = new InputReader(new BufferedReader(new InputStreamReader(System.in)));
            out = new PrintWriter(new OutputStreamWriter(System.out));
            solve(in, out);
        }

        in.reader.close();
        out.close();
    }

    public static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(BufferedReader reader) {
            this.reader = reader;
            tokenizer = null;
        }

        public String next() throws IOException{
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }

            return tokenizer.nextToken();
        }

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

}
