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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int *h, *h1;
void qs(int q, int w) {
  int e = q, r = w, t = h[q + (rand() % (w - q + 1))], y;
  do {
    while (h[e] < t) e++;
    while (h[r] > t) r--;
    if (e <= r) {
      y = h[e];
      h[e] = h[r];
      h[r] = y;
      y = h1[e];
      h1[e] = h1[r];
      h1[r] = y;
      e++;
      r--;
    }
  } while (e <= r);
  if (q < r) qs(q, r);
  if (e < w) qs(e, w);
}
int k(int e, int r) {
  for (; (e) && (r);)
    if (e > r)
      e %= r;
    else
      r %= e;
  return e + r;
}
int main() {
  int q, w, e, r, t = 0, y = 0, c, i = 1, *a = new int[2000],
                  *a1 = new int[2000], *s = new int[10000000],
                  *s1 = new int[10000000];
  long long *d = new long long[10000000];
  cin >> q;
  h = a;
  h1 = a1;
  for (w = 0; w < q; w++) {
    scanf("%d", &e);
    for (r = 0; r < t; r++) a[r] = k(a[r], e);
    a[t] = e;
    a1[t] = 1;
    t++;
    qs(0, t - 1);
    c = 1;
    for (r = 1; r < t; r++)
      if (a[r] == a[c - 1])
        a1[c - 1] += a1[r];
      else {
        a[c] = a[r];
        a1[c] = a1[r];
        c++;
      }
    t = c;
    for (r = 0; r < t; r++) {
      s[y] = a[r];
      s1[y] = a1[r];
      y++;
    }
  }
  h = s;
  h1 = s1;
  qs(0, y - 1);
  c = 1;
  d[0] = s1[0];
  for (r = 1; r < y; r++)
    if (s[r] == s[c - 1])
      d[c - 1] += s1[r];
    else {
      s[c] = s[r];
      d[c] = s1[r];
      c++;
    }
  y = c;
  for (; (i << 1) <= y; i <<= 1)
    ;
  for (cin >> q; q; q--) {
    scanf("%d", &w);
    t = 0;
    for (r = i; r; r >>= 1) {
      e = t + r;
      if ((e < y) && (s[e] <= w)) t = e;
    }
    if (s[t] == w)
      printf("%I64d\n", d[t]);
    else
      printf("0\n");
  }
  return 0;
}