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.*;

public class C {

	static int query(int l, int r, SparseTable st) {
		return st.query(l, r);
	}

	static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), a[] = new int[n];
		HashMap<Integer, Long> map = new HashMap<Integer, Long>();
		for (int i = 0; i < n; i++)
			a[i] = sc.nextInt();
		SparseTable st = new SparseTable(a);
		for (int l = 0; l < n; l++) {
			for (int nxt = l; nxt < n;) {
				int currgcd = query(l, nxt, st);
				int lo = nxt, hi = n - 1, farthest = nxt;
				while (lo <= hi) {
					int mid = lo + hi >> 1;
					if (query(l, mid, st) == currgcd) {
						farthest = mid;
						lo = mid + 1;
					} else
						hi = mid - 1;
				}
				int newLen = farthest - nxt + 1;
				map.put(currgcd, map.getOrDefault(currgcd, 0L) + newLen);
				nxt = farthest + 1;

			}
		}

		int q = sc.nextInt();
		while (q-- > 0)
			out.println(map.getOrDefault(sc.nextInt(), 0L));
		out.close();

	}

	static class SparseTable {

		int[] a, log, table[];

		SparseTable(int[] a) {
			this.a = a;
			int n = a.length;
			log = new int[n + 1];
			for (int i = 2; i <= n; i++)
				log[i] = log[i / 2] + 1;
			table = new int[log[n] + 1][n];
			for (int i = 0; i < n; i++)
				table[0][i] = a[i];
			for (int i = 1, len = 2; len <= n; i++, len <<= 1)
				for (int j = 0; j + len <= n; j++) {
					int u = table[i - 1][j], v = table[i - 1][j + len / 2];
					table[i][j] = gcd(u, v);
				}

		}

		int query(int l, int r) {
			int len = r - l + 1;
			int lg = log[len];
			int u = table[lg][l];
			int v = table[lg][r - (1 << lg) + 1];
			return gcd(u, v);
		}

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

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

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

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

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

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

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

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

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

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}