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 MAX = 100005;
const int mod = 6209989;
const int LOG = 17;
int LOG2[MAX];
int n, q;
int arr[MAX];
int dp[MAX][LOG + 1];
struct Node {
  int num;
  unsigned long long data;
  Node *next;
  Node(int NUM, int D, Node *N = NULL) : num(NUM), data(D), next(N) {}
  Node() : num(0), data(0), next(NULL) {}
} ans[mod + 5];
int gcd(int x, int y) {
  int z = y;
  while (x % y != 0) {
    z = x % y;
    x = y;
    y = z;
  }
  return z;
}
void sparse_table(int n) {
  for (int i = 1; i <= n; i++) dp[i][0] = arr[i];
  for (int j = 1; (1 << j) <= n; j++)
    for (int i = 1; i + (1 << j) - 1 <= n; i++) {
      dp[i][j] = gcd(dp[i][j - 1], dp[i + (1 << (j - 1))][j - 1]);
    }
}
int ask(int l, int r) {
  if (l == r) return dp[r][0];
  int k = log((r - l + 1) * 1.0) / log(2.0);
  return gcd(dp[l][k], dp[r - (1 << k) + 1][k]);
}
int searchR(int key, int left, int lf) {
  int rh = n, mid;
  while (lf <= rh) {
    mid = (lf + rh) / 2;
    if (ask(left, mid) != key)
      rh = mid - 1;
    else
      lf = mid + 1;
  }
  return rh;
}
void calc(int i) {
  int key;
  for (int l = i, r = i; r <= n; ++r) {
    l = r;
    key = ask(i, r);
    r = searchR(key, i, l);
    int pos = key % mod;
    Node *p = &ans[pos];
    bool flag = false;
    while (p->next != NULL) {
      if (p->num == key) {
        p->data += r - l + 1;
        flag = true;
        break;
      }
      p = p->next;
    }
    if (!flag) {
      if (p->num == key)
        p->data += r - l + 1;
      else
        p->next = new Node(key, r - l + 1, NULL);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> arr[i];
  }
  sparse_table(n);
  for (int i = 1; i <= n; ++i) calc(i);
  cin >> q;
  int key;
  while (q--) {
    cin >> key;
    int pos = key % mod;
    Node *p = &ans[pos];
    bool flag = false;
    while (p->next != NULL) {
      if (p->num == key) {
        cout << (p->data) << '\n';
        flag = true;
        break;
      }
      p = p->next;
    }
    if (!flag) {
      if (p->num == key)
        cout << (p->data);
      else
        cout << '0';
      cout << '\n';
    }
  }
  return 0;
}