#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int in[100005], queries[300005];
map<int, long long> res;
int main() {
  ios_base::sync_with_stdio(false);
  int n, a, k, q;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> in[i];
  cin >> q;
  for (int i = 0; i < q; i++) cin >> queries[i];
  map<int, int> divisors;
  map<int, int> nextDivisors;
  for (int i = 0; i < n; i++) {
    nextDivisors.clear();
    for (map<int, int>::iterator p = divisors.begin(); p != divisors.end();
         p++) {
      nextDivisors[gcd(p->first, in[i])] += p->second;
    }
    nextDivisors[in[i]]++;
    swap(nextDivisors, divisors);
    for (map<int, int>::iterator p = divisors.begin(); p != divisors.end(); p++)
      res[p->first] += p->second;
  }
  for (int h = 0; h < q; h++) cout << res[queries[h]] << '\n';
}
