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


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        HashMap<Integer, Long> cnt = new HashMap<>();
        Pair adjList[][] = new Pair[n][32];
        int[] size = new int[n];
        adjList[n - 1][size[n - 1]++] = new Pair(a[n - 1], n - 1);
        cnt.put(a[n - 1], 1l);
        for (int i = n - 2; i >= 0; i--) {
            int g = gcd(a[i], adjList[i + 1][0].val);
            int idx = adjList[i + 1][0].idx;
            if (g == a[i])
                adjList[i][size[i]++] = (new Pair(g, g == 1 ? n - 1 : idx));
            else {
                adjList[i][size[i]++] = (new Pair(a[i], i));
                adjList[i][size[i]++] = (new Pair(g, g == 1 ? n - 1 : idx));
            }
            for (int j = 1; j < size[i + 1] && g != 1; j++) {
                g = gcd(g, adjList[i + 1][j].val);
                if (g == adjList[i][size[i] - 1].val) adjList[i][size[i] - 1].idx = adjList[i + 1][j].idx;
                else
                    adjList[i][size[i]++] = (new Pair(g, g == 1 ? n - 1 : adjList[i + 1][j].idx));
            }
            cnt.put(a[i], cnt.getOrDefault(a[i], 0l) + 1);
            for (int j = 0; j < size[i]; j++) {
                int v = adjList[i][j].val;
                idx = adjList[i][j].idx;
                cnt.put(v, cnt.getOrDefault(v, 0l) + idx - (j == 0 ? i : adjList[i][j - 1].idx));
            }
        }
        int q = sc.nextInt();
        while (q-- > 0)
            out.println(cnt.getOrDefault(sc.nextInt(), 0l));
        out.flush();
        out.close();
    }

    static int gcd(int n, int m) {
        return m == 0 ? n : gcd(m, n % m);
    }

    static class Pair {
        int val, idx;

        public Pair(int val, int idx) {
            this.val = val;
            this.idx = idx;
        }

        @Override
        public String toString() {
            return "Pair{" +
                    "val=" + val +
                    ", idx=" + idx +
                    '}';
        }
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }


        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

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

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }


        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }


        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }


}