#include <bits/stdc++.h>
using namespace std;
int n, q, c;
int a[100005];
map<int, long long> ans;
map<int, int> last;
map<int, int> now;
map<int, int>::iterator it;
int gcd(int a, int b) {
  if (!b) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  ans.clear();
  for (int i = 0; i < n; i++) {
    swap(last, now);
    now.clear();
    for (it = last.begin(); it != last.end(); it++) {
      now[gcd(it->first, a[i])] += it->second;
    }
    now[a[i]]++;
    for (it = now.begin(); it != now.end(); it++) {
      ans[it->first] += it->second;
    }
  }
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &c);
    printf("%lld\n", ans[c]);
  }
  return 0;
}
