#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  int n;
  scanf("%d", &n);
  map<long long, long long> ans, g, curr;
  for (int i = 0; i < n; i++) {
    long long k;
    curr.clear();
    scanf("%lld", &k);
    for (auto &p : g) curr[gcd(p.first, k)] += p.second;
    curr[k]++;
    swap(curr, g);
    for (auto &p : g) ans[p.first] += p.second;
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    long long x;
    scanf("%lld", &x);
    printf("%lld\n", ans[x]);
  }
  return 0;
}
