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.util.*;
import java.io.*;
/*NO RESPECT*/

public class Main implements Runnable {
static boolean showTime = false;		
        private int gcd(int m, int n){
            if(n == 0) return m;
            else return gcd(n, m % n);  
        }

	public void solve() throws IOException {
		int n = nextInt();
                int[] a = new int[n];
                for(int i = 0; i < n; i++) a[i] = nextInt();
                
                Map<Integer, Long> result = new TreeMap<Integer, Long>();
                
                Map<Integer, Integer> prev = new TreeMap<>();
                Map<Integer, Integer> now = new TreeMap<>();
                
                for(int i = 0; i < n; i++){
                    now.clear();
                    now.put(a[i], 1);
                    for(Map.Entry<Integer, Integer> me : prev.entrySet()){
                        int gcd = gcd(a[i], me.getKey());
                        if(!now.containsKey(gcd))
                            now.put(gcd, me.getValue());
                        else
                            now.put(gcd, now.get(gcd) + me.getValue());
                    }
                    
                    for(Map.Entry<Integer, Integer> me : now.entrySet()){
                        if(result.containsKey(me.getKey())){
                            result.put(me.getKey(), result.get(me.getKey()) + me.getValue());
                        }
                        else{
                            result.put(me.getKey(), 0L + me.getValue());
                        }
                    }
                    
                    Map<Integer, Integer> t = now;
                    now = prev;
                    prev = t;
                }
                
                int Q = nextInt();
                for(int i = 0; i < Q; i++){
                    int v = nextInt();
                    if(result.containsKey(v))
                        out.println(result.get(v));
                    else
                        out.println(0);
                }
                
	}

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

        public void debug(Object... arr){
            System.out.println(Arrays.deepToString(arr));
        }

        public void print1Int(int[] a){
                for(int i = 0; i < a.length; i++)
                        System.out.print(a[i] + " ");
                System.out.println();
        }
        
        public void print2Int(int[][] a){
                for(int i = 0; i < a.length; i++){
                        for(int j = 0; j < a[0].length; j++){
                                System.out.print(a[i][j] + " ");
                        }
                        System.out.println();
                }
        }
        
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
                        out = new PrintWriter(System.out);
			tok = null;
			long start = System.currentTimeMillis();
			solve();
                        long end = System.currentTimeMillis();
                        if(showTime)System.err.println( (end - start) / 1000.0);
			in.close();
                        out.close();
		} catch (IOException e) {
			System.exit(0);
		}
	}

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

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

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

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
        PrintWriter out;
	BufferedReader in;
	StringTokenizer tok;
}