#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const long long inf = (((long long)1) << 61) + 5;
const int N = 100005;
map<int, long long> mp, mp1, mp2;
map<int, long long>::iterator it;
int a[N];
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  mp[a[0]]++, mp1[a[0]]++;
  for (int i = 1; i < n; i++) {
    mp[a[i]]++;
    mp2[a[i]]++;
    for (it = mp1.begin(); it != mp1.end(); it++) {
      int x = gcd(it->first, a[i]);
      mp2[x] += it->second;
      mp[x] += it->second;
    }
    mp1.clear();
    for (it = mp2.begin(); it != mp2.end(); it++) {
      mp1[it->first] = it->second;
    }
    mp2.clear();
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int x;
    scanf("%d", &x);
    printf("%I64d\n", mp[x]);
  }
  return 0;
}
