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;
const int N = 100500;
const int LOG_N = 18;
int gcd(int a, int b) {
  if (a != 0) return gcd(b % a, a);
  return b;
}
struct SparseTable {
  int pw2[N];
  int st[LOG_N][N];
  SparseTable() : pw2(), st() {}
  void build(int a[], int n) {
    pw2[1] = 0;
    for (int i = 2; i <= n; i++) {
      pw2[i] = pw2[i - 1];
      if ((1 << (pw2[i] + 1)) <= i) pw2[i]++;
    }
    for (int i = 0; i < n; i++) st[0][i] = a[i];
    for (int i = 1; i < LOG_N; i++)
      for (int j = 0; j + (1 << i) <= n; j++)
        st[i][j] = gcd(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
  }
  int get(int a, int b) {
    int k = pw2[b - a + 1];
    return gcd(st[k][a], st[k][b - (1 << k) + 1]);
  }
};
int n, q;
int a[N];
SparseTable sparse;
map<int, long long> answer;
void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sparse.build(a, n);
  for (int i = 0; i < n; i++) {
    0;
    int j = i;
    while (j < n) {
      int my_gcd = sparse.get(i, j);
      int l = j, r = n;
      while (r - l > 1) {
        int m = (l + r) / 2;
        if (sparse.get(i, m) < my_gcd)
          r = m;
        else
          l = m;
      }
      0;
      answer[my_gcd] += r - j;
      j = r;
    }
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int x;
    scanf("%d", &x);
    auto it = answer.find(x);
    if (it == answer.end())
      printf("0\n");
    else
      printf("%lld\n", it->second);
  }
}
int main() {
  solve();
  0;
  return 0;
}