#include <bits/stdc++.h>
using namespace std;
template <typename T>
vector<int> readVector(int n) {
  vector<T> res(n);
  for (int i = 0; i < n; i++) cin >> res[i];
  return res;
}
int gcd(int a, int b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  auto v = readVector<int>(n);
  map<int, int> divisors;
  map<int, int> nextDivisors;
  map<int, long long int> results;
  for (int i = 0; i < n; i++) {
    nextDivisors.clear();
    for (auto &p : divisors) {
      nextDivisors[gcd(v[i], p.first)] += p.second;
    }
    nextDivisors[v[i]]++;
    swap(nextDivisors, divisors);
    for (auto &p : divisors) {
      results[p.first] += p.second;
    }
  }
  int q, x;
  cin >> q;
  while (q--) {
    cin >> x;
    cout << results[x] << endl;
  }
  return 0;
}
