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;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = 0;
  while (!isdigit(c)) {
    if (c == '-') flag = 1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 3) + (x << 1) + c - '0';
    c = getchar();
  }
  x = flag ? -x : x;
}
template <class T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
const int maxn = 1e5 + 10;
const int mod = 998244353;
int n, q, a[maxn], dp[maxn][35];
int gcd(int x, int y) { return (y == 0) ? x : gcd(y, x % y); }
void build() {
  for (int j = 0; j <= 30; ++j) {
    for (int i = 1; i <= n; ++i) {
      if (j == 0) {
        dp[i][0] = a[i];
        continue;
      }
      if (i + (1 << j) - 1 > n)
        continue;
      else {
        dp[i][j] = gcd(dp[i][j - 1], dp[i + (1 << (j - 1))][j - 1]);
      }
    }
  }
}
int query(int l, int r) {
  if (l == r) return a[l];
  int k = 1, j = 0;
  while (k < (r - l + 1)) {
    k *= 2, ++j;
  }
  return gcd(dp[l][j - 1], dp[r - (1 << (j - 1)) + 1][j - 1]);
}
int binary(int g, int l, int r) {
  int re = n;
  int temp = l;
  while (l <= r) {
    int mid = (l + r) / 2;
    int g1 = gcd(g, query(temp, mid));
    if (g1 < g) {
      r = mid - 1;
      re = min(re, mid);
    } else
      l = mid + 1;
  }
  return re;
}
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(a[i]);
  }
  build();
  map<int, ll> ans;
  for (int i = 1; i <= n; ++i) {
    int p = i, p1, g = a[i], g1;
    if (g == 1) {
      ans[1] += n - p + 1;
      continue;
    }
    if (p == n) {
      ++ans[g];
      break;
    }
    while (g != 1 && p < n) {
      p1 = binary(g, p, n);
      g1 = gcd(g, query(p, p1));
      if (p1 == n && g1 == g) {
        ans[g1] += n - p + 1;
        break;
      }
      ans[g] += p1 - p;
      p = p1;
      g = g1;
      if (p1 == n) {
        ++ans[g1];
        break;
      }
      if (g == 1) {
        ans[1] += n - p1 + 1;
      }
    }
  }
  read(q);
  while (q--) {
    int c;
    read(c);
    printf("%lld\n", ans[c]);
  }
}