#include <bits/stdc++.h>
using namespace std;
vector<int> A(100001);
const int MAXLG = 18;
unordered_map<int, long long> SAVE;
int __gcd(int x, int y) {
  int save;
  for (; y != 0;) {
    save = y;
    y = x % y;
    x = save;
  }
  return x;
}
int main() {
  int N, M, Q, i, j, k, l;
  scanf("%d", &N);
  for (i = 0; i < N; ++i) scanf("%d", &A[i]);
  map<int, int> divisors;
  map<int, int> ndivisors;
  for (i = N - 1; i >= 0; --i) {
    ndivisors.clear();
    for (auto &p : divisors) ndivisors[__gcd(p.first, A[i])] += p.second;
    ndivisors[A[i]]++;
    for (auto &p : ndivisors) SAVE[p.first] += p.second;
    swap(ndivisors, divisors);
  }
  scanf("%d", &Q);
  for (; Q; --Q) {
    int x;
    scanf("%d", &x);
    printf("%I64d\n", SAVE.count(x) ? SAVE[x] : 0LL);
  }
  return 0;
}
