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 comment(linker, "/STACK:100000000000000")
using namespace std;
map<int, long long> mp;
int n, arr[100001], table[100001][20], q[3 * 100001], m;
int Log[100001];
vector<int> tmp, best;
int GCD(int a, int b) {
  if (b == 0) return a;
  return GCD(b, a % b);
}
void init(int n) {
  for (int i = 0; i < n; i++) table[i][0] = arr[i];
  for (int i = 1; i < Log[n] + 1; i++)
    for (int j = 0; j + (1 << i) - 1 < n; j++)
      table[j][i] = GCD(table[j][i - 1], table[j + (1 << (i - 1))][i - 1]);
}
int get_gcd(int l, int r) {
  int lg = Log[r - l + 1];
  return GCD(table[l][lg], table[r - (1 << lg) + 1][lg]);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  int lim = 2, lg = 0;
  for (int i = 0; i < 100001; i++) {
    if (i == lim) {
      lg++;
      lim *= 2;
    }
    Log[i] = lg;
  }
  init(n);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &q[i]);
    mp[q[i]] = 0;
  }
  for (int i = 0; i < n; i++)
    for (int j = n - 1; j >= i;) {
      int l = i, r = j + 1;
      int g = get_gcd(l, r - 1), x = 0;
      while (l < r) {
        int mid = (l + r) / 2;
        int tmp = get_gcd(i, mid);
        if (tmp == g)
          x = mid, r = mid;
        else
          l = mid + 1;
      }
      if (mp.find(g) != mp.end()) mp[g] += j - x + 1;
      j = x - 1;
    }
  for (int i = 0; i < m; i++) printf("%I64d\n", mp[q[i]]);
  return 0;
}