#include <bits/stdc++.h>
using namespace std;
int MCD(int a, int b) {
  if (b > a) return MCD(b, a);
  return (b == 0 ? a : MCD(b, a % b));
}
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  map<int, long long int> M;
  queue<map<int, long long int> > Q;
  Q.push(M);
  map<int, long long int>::iterator it;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    map<int, long long int> MM;
    ++MM[x];
    for (it = Q.front().begin(); it != Q.front().end(); ++it) {
      MM[MCD(it->first, x)] += (it->second);
      M[it->first] += (it->second);
    }
    Q.push(MM);
    Q.pop();
  }
  for (it = Q.front().begin(); it != Q.front().end(); ++it) {
    M[it->first] += (it->second);
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int x;
    cin >> x;
    it = M.find(x);
    if (it == M.end())
      cout << 0 << endl;
    else
      cout << it->second << endl;
  }
}
