#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  int n;
  cin >> n;
  map<int, long long> cnt;
  map<int, long long> last;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    map<int, long long> next;
    last[x]++;
    for (map<int, long long>::iterator j = last.begin(); j != last.end(); j++) {
      int g = gcd(j->first, x);
      next[g] += j->second;
      cnt[g] += j->second;
    }
    last = next;
  }
  int q;
  cin >> q;
  while (q--) {
    int x;
    cin >> x;
    cout << cnt[x] << '\n';
  }
  return 0;
}
