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>
#pragma GCC optimize(3)
inline void read(int &x) { scanf("%d", &x); }
inline void read(long long &x) { scanf("%I64d", &x); }
inline void read(double &x) { scanf("%lf", &x); }
inline void read(long double &x) {
  double tmp;
  read(tmp);
  x = tmp;
}
template <class T>
inline void read(T *a, int n) {
  for (int i = (0); i < (n); ++i) read(a[i]);
}
template <class T1, class T2>
inline void read(T1 &a, T2 &b) {
  read(a);
  read(b);
}
template <class T1, class T2, class T3>
inline void read(T1 &a, T2 &b, T3 &c) {
  read(a);
  read(b);
  read(c);
}
template <class T1, class T2, class T3, class T4>
inline void read(T1 &a, T2 &b, T3 &c, T4 &d) {
  read(a);
  read(b);
  read(c);
  read(d);
}
inline void write(int x) { printf("%d", x); }
inline void write(long long x) { printf("%I64d", x); }
inline void write(double x) { printf("%.10lf", x); }
inline void write(long double x) { printf("%.10lf", (double)x); }
template <class T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
template <class T>
inline void writeln(T *a, int n) {
  for (int i = (0); i < (n); ++i) write(a[i]);
  putchar('\n');
}
template <class T>
inline void writelnln(T *a, int n) {
  for (int i = (0); i < (n); ++i) writeln(a[i]);
}
inline int gcd(int x, int y) {
  while (y) {
    int t = x % y;
    x = y;
    y = t;
  }
  return x;
}
int a[17][100009], n;
std::map<int, long long> ans;
int main() {
  int n;
  read(n);
  read(a[0], n);
  a[0][n] = 1;
  for (int j = (1); j <= (16); ++j)
    for (int i = (0); i <= (n); ++i) {
      int tmp = i + (1 << (j - 1));
      if (tmp <= n)
        a[j][i] = gcd(a[j - 1][i], a[j - 1][tmp]);
      else
        a[j][i] = a[j - 1][i];
    }
  for (int i = (0); i < (n); ++i) {
    int cg = a[0][i], ci = i, li = i;
    while (cg > 1) {
      for (int j = (16); j >= (0); --j)
        if (a[j][ci] % cg == 0) {
          ci += (1 << j);
          if (ci > n) ci -= n;
        }
      ans[cg] += (long long)(ci - li);
      li = ci;
      cg = gcd(cg, a[0][ci]);
    }
    ans[1] += (long long)(n - ci);
  }
  int q;
  read(q);
  while (q--) {
    int x;
    read(x);
    writeln(ans[x]);
  }
  return 0;
}