Given a sequence of integers a1, ..., an and q queries x1, ..., xq on it. For each query xi you have to count the number of pairs (l, r) such that 1 ≤ l ≤ r ≤ n and gcd(al, al + 1, ..., ar) = xi.

<image> is a greatest common divisor of v1, v2, ..., vn, that is equal to a largest positive integer that divides all vi.

Input

The first line of the input contains integer n, (1 ≤ n ≤ 105), denoting the length of the sequence. The next line contains n space separated integers a1, ..., an, (1 ≤ ai ≤ 109).

The third line of the input contains integer q, (1 ≤ q ≤ 3 × 105), denoting the number of queries. Then follows q lines, each contain an integer xi, (1 ≤ xi ≤ 109).

Output

For each query print the result in a separate line.

Examples

Input

3
2 6 3
5
1
2
3
4
6


Output

1
2
2
0
1


Input

7
10 20 3 15 1000 60 16
10
1
2
3
4
5
6
10
20
60
1000


Output

14
0
2
2
2
0
2
2
1
1


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
    static BufferedReader br;
    static StringTokenizer st;
    static PrintWriter out;
    
    public static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
    
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    
    static int n, q;
    static int[][] t;
    static int[] a;
    static HashMap<Integer, Long> M;
    
    static int gcd(int a, int b) {
        while (a > 0 && b > 0) {
            if (a >= b) {
                a %= b;
            } else {
                b %= a;
            }
        }
        return a + b;
    }
    
    static void add(int x, int d) {
        if (M.containsKey(x)) {
            M.put(x, M.get(x) + d);
        } else {
            M.put(x, 0L + d);
        }
    }
    
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        n = nextInt();
        a = new int[n];
        t = new int[17][n];
        for (int i = 0; i < n; ++i) {
            a[i] = nextInt();
            t[0][i] = a[i];
        }
        for (int k = 1; k <= 16; ++k) {
            int pd = (1<<(k - 1));
            for (int i = 0; i + 2 * pd <= n; ++i) {             
                t[k][i] = gcd(t[k - 1][i], t[k - 1][i + pd]);
            }
        }
        
        M = new HashMap<>();
        for (int i = 0; i < n; ++i) {
            int j = i, x = a[i];
            while (j < n && x > 1) {
                int jj = j;
                for (int k = 16; jj < n && k >= 0; --k) if (t[k][jj] > 0 && t[k][jj] % x == 0) {
                    jj += (1<<k);
                }
                add(x, jj - j);
                j = jj;
                if (j < n) {
                    x = gcd(x, a[j]);
                }
            }
            if (x == 1) {
                add(x, n - j);
            }
        }
        int q = nextInt();
        for (int i = 0; i < q; ++i) {
            int x = nextInt();
            out.println(M.containsKey(x) ? M.get(x) : 0);
        }
        out.close();
    }

}
