Problem: 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

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;

public class D2 {

    FastScanner in;
    PrintWriter out;
    
    int gcd(int a, int b) {
        if (a == 0) {
            return b;
        }
        return gcd(b % a, a);
    }
    
    class STable {
        int[][] gcd;
        int size;
        
        public STable(int[] a) {
            this.size = a.length;
            gcd = new int[20][size];
            
            
            gcd[0] = a.clone();
            for (int i = 1; i < 20; i++) {
                for (int j = 0; j < a.length; j++) {
                    int nxt = Math.min(a.length - 1, j + (1 << (i - 1)));
                    gcd[i][j] = gcd(gcd[i - 1][j], gcd[i - 1][nxt]);
                }
            }
        }
        
        int get(int from, int to) {
            int cnt = to - from + 1;
            int log = 31 - Integer.numberOfLeadingZeros(cnt);
            return gcd(gcd[log][from], gcd[log][to - (1 << log) + 1]);
        }
        
        
    }

    void solve() {
        int n = in.nextInt();
        int[] a=  new int[n];
        
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        
        STable st = new STable(a);
        Map<Integer, Long> cache = new HashMap<Integer, Long>();
        
        for (int i = 0; i < n; i++) {
            
            int curR = i;
            
            while (curR < n) {
                int l = curR, r = n;
                
                int gg = st.get(i, curR);
                while (l + 1 < r) {
                    int m = (l + r) >> 1;
                    
                    if (gg == st.get(i, m)) {
                        l = m;
                    } else {
                        r = m;
                    }
                }
                
                if (cache.containsKey(gg)) {
                    cache.put(gg, cache.get(gg) + l - curR + 1);
                } else {
                    cache.put(gg, (long) (l - curR + 1));
                }
                curR = r;
            }
        }
        
        
        int Q = in.nextInt();
        for (int q = 0; q < Q; q++) {
            int x = in.nextInt();
            if (cache.containsKey(x)) {
                out.println(cache.get(x));
            } else {
                out.println(0);
            }
        }
    }

    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

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

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

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

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

    public static void main(String[] args) {
        new D2().run();
    }
}