#include <bits/stdc++.h>
using namespace std;
map<int, long long> mp;
map<int, long long> mp2;
map<int, long long> ans;
map<int, long long>::iterator it;
int a[100010];
int gcd(int a, int b) {
  if (a < b) swap(a, b);
  while (b) {
    int temp = a % b;
    a = b;
    b = temp;
  }
  return a;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  ans[a[1]] = 1;
  mp[a[1]] = 1;
  for (int i = 2; i <= n; i++) {
    int x = a[i];
    ans[x]++;
    mp2[x]++;
    for (it = mp.begin(); it != mp.end(); it++) {
      int v = gcd(x, it->first);
      ans[v] += it->second;
      mp2[v] += it->second;
    }
    mp.clear();
    for (it = mp2.begin(); it != mp2.end(); it++) {
      mp[it->first] = it->second;
    }
    mp2.clear();
  }
  int Q;
  scanf("%d", &Q);
  for (int i = 0; i < Q; i++) {
    int x;
    scanf("%d", &x);
    cout << ans[x] << endl;
  }
  return 0;
}
