#include <bits/stdc++.h>
using namespace std;
const int inf = 2e9;
const int MOD = 1e9 + 7;
const int N = 1e5 + 10;
int a[N];
int gcd(int x, int y) {
  while (y) {
    int tmp = y;
    y = x % y;
    x = tmp;
  }
  return x;
}
int main() {
  int n, q;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  map<int, long long> ans;
  map<int, int> div;
  map<int, int> ndiv;
  for (int i = 1; i <= n; i++) {
    ndiv.clear();
    for (auto &j : div) ndiv[gcd(j.first, a[i])] += j.second;
    ndiv[a[i]]++;
    swap(div, ndiv);
    for (auto &j : div) ans[j.first] += j.second;
  }
  scanf("%d", &q);
  while (q--) {
    int x;
    scanf("%d", &x);
    printf("%I64d\n", ans[x]);
  }
}
