#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
long long n, q, x;
long long a[100005], b[100005];
map<long long, long long> m[100005], ans;
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    for (auto j : m[i - 1]) {
      m[i][gcd(a[i], j.first)] += j.second;
    }
    m[i][a[i]]++;
    for (auto j : m[i]) ans[j.first] += j.second;
  }
  cin >> q;
  while (q--) {
    cin >> x;
    cout << ans[x] << endl;
  }
  return 0;
}
