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
// package CF;

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

public class D {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int [] a = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		SparseTable s = new SparseTable(a);
		HashMap<Integer, Long> mp = new HashMap<>();
		for (int i = 0; i < a.length; i++) {
			int idx = i;
			while(true){
				int lo = idx+1, hi = n-1, ans = n;
				int g = s.query(i, idx);
				while(lo <= hi){
					int mid = (lo + hi)/2;
					if(s.query(i, mid) < g)
					{
						ans = mid; 
						hi = mid-1;
					}
					else lo = mid+1;
				}
				mp.put(g, mp.getOrDefault(g, 0L) + ans-idx);
				idx = ans;
				if(ans == n)
					break;
			}
		}
		int q = sc.nextInt();
		while(q-- > 0){
			out.println(mp.getOrDefault(sc.nextInt(), 0L));
		}
		out.flush();
		out.close();
	}
	static int gcd(int a, int b){
		return b == 0?a:gcd(b, a%b);
	}
	static class SparseTable {                                          

		int A[], log [], SpT[][];

		SparseTable(int[] A) 
		{
			int n = A.length;	this.A = A;
			int k = (int)Math.floor(Math.log(n) / Math.log(2)) + 1;
			SpT = new int[n][k];

			for (int i = 0; i < n; i++) 
				SpT[i][0] = A[i]; 					// RMQ of sub array starting at index i and of length 2^0=1

			//overall time complexity = O(n log n)
			for (int j = 1; (1<<j) <= n; j++) 				
				for (int i = 0; i + (1<<j) - 1 < n; i++)    
					SpT[i][j] = gcd(SpT[i+(1<<(j-1))][j-1], SpT[i][j-1]);
			
			log = new int[n+1];
			for (int i = 1, cur = 0; i < log.length; i++) {
				log[i] = 1<<cur+1 < i?++cur:cur;
			}
		}

		int query(int i, int j) 
		{
			int k = log[j-i+1]; // 2^k <= (j-i+1)

			return gcd(SpT[i][k], SpT[j-(1<<k)+1][k]);
		} 
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

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

		public Scanner(FileReader fileReader) {
			br = new BufferedReader(fileReader);
		}

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

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

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

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

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