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.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;


public class D {

    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;
    static int[][]t;
    static int[]log2;
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int[]a = new int[n+1];
        for (int i = 1; i <= n; i++) {
            a[i] = nextInt();
        }
        int L = 0;
        while ((1 << L) < n)
            L++;
        t = new int[n+1][L+1];
        for (int i = 1; i <= n; i++) {
            t[i][0] = a[i];
        }
        for (int i = 1; i <= L; i++) {
            for (int j = 1; j <= n; j++) {
                if (j+(1 << i)-1 <= n)
                    t[j][i] = gcd(t[j][i-1], t[j+(1 << (i-1))][i-1]);
            }
        }
        log2 = new int[n+1];
        for (int i = 1; i <= n; i++) {
            while ((1 << (log2[i]+1)) <= i)
                log2[i]++;
        }
        Map<Integer, Long> map = new TreeMap<>();
        for (int i = 1; i <= n; i++) {
            if (!map.containsKey(a[i]))
                map.put(a[i], 1l);
            else
                map.put(a[i], map.get(a[i])+1);
        }
        for (int i = 1; i < n; i++) {
            int g = gcd(a[i], a[i+1]);
            int left = i+1;
            int last = i;
            while (left <= n) {
                int right = n+1;
                while (right-left > 1) {
                    int middle = (left+right) >> 1;
                    if (get_gcd(left, middle, g)) {
                        left = middle;
                    }
                    else
                        right = middle;
                }
                if (!map.containsKey(g))
                    map.put(g, 1l*(left-last));
                else
                    map.put(g, map.get(g)+1l*(left-last));
                if (right <= n) {
                    g = gcd(g, a[right]);
                }
                left = right;
                last = left-1;
            }
        }
        int q = nextInt();
        for (int i = 1; i <= q; i++) {
            int x = nextInt();
            if (!map.containsKey(x))
                pw.println(0);
            else
                pw.println(map.get(x));
        }
        pw.close();
    }
    private static boolean get_gcd(int L, int R, int g) {
        if (L > R)
            return false;
        int k = log2[R-L+1];
        return t[L][k] % g==0 && t[R-(1 << k)+1][k] % g==0; 
    }
    private static int gcd(int a, int b) {
        if (b==0)
            return a;
        return gcd(b, a % b);
    }
    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    private static String next() throws IOException {
        while (st==null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}
