#include <bits/stdc++.h>
using namespace std;
int chh;
const int N = 100005;
int n, m;
int a[N];
map<int, long long> ans;
map<int, int> h[2];
int gcd(int x, int y) { return x % y ? gcd(y, x % y) : y; }
int main() {
  int x, y, pre, now, d;
  while (~scanf("%d", &n)) {
    for (int i = 0; i < (n); i++) scanf("%d", &a[i]);
    now = 0, pre = 1;
    ans.clear(), h[now].clear();
    ans[a[n - 1]] = 1, h[now][a[n - 1]] = 1;
    for (int i = (n - 2); i >= (0); i--) {
      swap(now, pre);
      h[now].clear();
      h[now][a[i]] = 1;
      ans[a[i]] += 1LL;
      for (__typeof__((h[pre]).begin()) it = (h[pre]).begin();
           it != (h[pre]).end(); it++) {
        x = it->first, y = it->second;
        d = gcd(a[i], x);
        h[now][d] += y;
        ans[d] += (long long)y;
      }
    }
    scanf("%d", &m);
    while (m--) {
      scanf("%d", &x);
      cout << ans[x] << '\n';
    }
  }
  return 0;
}
