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 + 6];
inline int read() {
  int X = 0, w = 0;
  char ch = 0;
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return X;
}
inline void write(unsigned long long x) {
  unsigned long long y = 10;
  int len = 1;
  while (y <= x) {
    y *= 10;
    len++;
  }
  while (len--) {
    y /= 10;
    putchar(x / y + 48);
    x %= y;
  }
}
inline int GCD(int a, int b) { return b == 0 ? a : GCD(b, a % b); }
inline int gcd(int a, int b) {
  if (a > b)
    return GCD(a, b);
  else
    return GCD(b, a);
}
void init() {
  for (int j = 1; j <= LOG; ++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]);
    }
  LOG2[0] = -1;
  for (int i = 1; i <= n; ++i) LOG2[i] = LOG2[i >> 1] + 1;
}
int searchGCD(int l, int r) {
  int k = LOG2[r - l + 1];
  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 (searchGCD(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 = searchGCD(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) {
    arr[i] = read();
    dp[i][0] = arr[i];
  }
  init();
  for (int i = 1; i <= n; ++i) calc(i);
  cin >> q;
  int key;
  while (q--) {
    key = read();
    int pos = key % MOD;
    Node *p = &ans[pos];
    bool flag = false;
    while (p->next != NULL) {
      if (p->num == key) {
        write(p->data);
        putchar('\n');
        flag = true;
        break;
      }
      p = p->next;
    }
    if (!flag) {
      if (p->num == key) {
        write(p->data);
        putchar('\n');
      } else {
        putchar('0');
        putchar('\n');
      }
    }
  }
  return 0;
}