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
// practice with rainboy
import java.io.*;
import java.util.*;

public class CF475D extends PrintWriter {
	CF475D() { super(System.out); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF475D o = new CF475D(); o.main(); o.flush();
	}

	static final int L = 30;
	static class V {
		int d;
		long k;
		V(int d, long k) {
			this.d = d; this.k = k;
		}
	}
	int compress(V[] vv, int m) {
		int h = 1;
		for (int i = 1; i < m; i++)
			if (vv[h - 1].d == vv[i].d)
				vv[h - 1].k += vv[i].k;
			else
				vv[h++] = vv[i];
		return h;
	}
	int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}
	void main() {
		int n = sc.nextInt();
		V[] vv_ = new V[L * n];
		V[] vv = new V[L];
		int m_ = 0, m = 0;
		while (n-- > 0) {
			int a = sc.nextInt();
			vv[m++] = new V(a, 1);
			int d = 0;
			for (int i = m - 1; i >= 0; i--)
				vv[i].d = d = gcd(d, vv[i].d);
			m = compress(vv, m);
			for (int i = 0; i < m; i++)
				vv_[m_++] = new V(vv[i].d, vv[i].k);
		}
		Arrays.sort(vv_, 0, m_, (u, v) -> u.d - v.d);
		m_ = compress(vv_, m_);
		int q = sc.nextInt();
		while (q-- > 0) {
			int d = sc.nextInt();
			int lower = -1, upper = m_;
			while (upper - lower > 1) {
				int i = (lower + upper) / 2;
				if (vv_[i].d <= d)
					lower = i;
				else
					upper = i;
			}
			println(lower >= 0 && vv_[lower].d == d ? vv_[lower].k : 0);
		}
	}
}
