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:
/*
javac D475.java && java D475
*/

import java.io.*;
import java.util.*;

public class D475 {
	public static void main(String[] args) { new D475(); }
	FS in = new FS();
	PrintWriter out = new PrintWriter(System.out);

	int n, q, x;
	int MAX = 100;
	int oo = (int)1e9 + 1313;
	int[] a, t[], s[];
	HashMap<Integer, Long> mp;

	D475() {
		n = in.nextInt();
		a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextInt();

		int tl = 0, tr = 0;
		int sl = 0, sr = 0;
		t = new int[MAX][2];
		s = new int[MAX][2];
		for (int i = 0; i < MAX; i++)
			for (int j = 0; j < 2; j++)
				s[i][j] = -oo;

		mp = new HashMap<>();
		for (int i = n - 1; i >= 0; i--) {
			sl = 0; sr = 0;
			s[sr][0] = a[i];
			s[sr][1] = 1;
			sr++;

			while (tl != tr) {
				s[sr][0] = gcd(a[i], t[tl][0]);
				s[sr][1] = 1 + t[tl][1];
				tl++; sr++;
			}
			Arrays.sort(s, (x1, x2) -> sort(x1, x2));

			int sz = 0;
			int[][] r = new int[MAX][2];
			int curG = s[0][0], curR = 0;
			for (int j = 0; j < sr; j++) {
				if (s[j][0] == curG)
					curR = s[j][1];
				else {
					r[sz][0] = curG;
					r[sz][1] = curR;
					sz++;
					curG = s[j][0];
					curR = s[j][1];
				}
			}
			r[sz][0] = curG;
			r[sz][1] = curR;
			sz++;

			int last = 0;
			for (int j = 0; j <= sz; j++) {
				curG = r[j][0];
				curR = r[j][1];
				mp.putIfAbsent(curG, 0L);
				mp.put(curG, mp.get(curG) + curR - last);
				last = curR;
			}
			
			for (int j = 0; j < sz; j++) {
				t[j][0] = r[j][0];
				t[j][1] = r[j][1];
			}
			for (int j = 0; j < MAX; j++)
				for (int k = 0; k < 2; k++)
					s[j][k] = -oo;
			tl = 0;
			tr = sz;
		}

		q = in.nextInt();
		while (q-- > 0) {
			x = in.nextInt();
			if (!mp.containsKey(x))
				out.println(0);
			else
				out.println(mp.get(x));
		}
		out.close();
	}

	int sort(int[] x1, int[] x2) {
		if (x1[0] == x2[0])
			return Integer.compare(x1[1], x2[1]);
		return -Integer.compare(x1[0], x2[0]);
	}
	
	int abs(int x) { return x < 0 ? -x : x; }
	long abs(long x) { return x < 0 ? -x : x; }
	double abs(double x) { return x < 0 ? -x : x; }
	int min(int x, int y) { return x < y ? x : y; }	
	int max(int x, int y) { return x > y ? x : y; }
	long min(long x, long y) { return x < y ? x : y; }	
	long max(long x, long y) { return x > y ? x : y; }
	double min(double x, double y) { return x < y ? x : y; }
	double max(double x, double y) { return x > y ? x : y; }
	int gcd(int x, int y) { while (y > 0) { x = y^(x^(y = x)); y %= x; } return x; }
	long gcd(long x, long y) { while (y > 0) { x = y^(x^(y = x)); y %= x; } return x; }
	long lcm(int x, int y) { return ((long) x / gcd(x, y)) * y; }
	long lcm(long x, long y) { return (x / gcd(x, y)) * y; }

	void sort(int[] arr) {
		int sz = arr.length, j;
		Random r = new Random();
		for (int i = 0; i < sz; i++) {
			j = r.nextInt(i + 1);
			arr[i] = arr[j]^(arr[i]^(arr[j] = arr[i]));
		} Arrays.sort(arr);
	}

	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
		double nextDouble() { return Double.parseDouble(next()); }
	}
}