#include <bits/stdc++.h>
using namespace std;
const int INF = 2 * int(1e9);
const long long INFll = 1ll * int(1e9) * int(1e9);
const int MOD = 1000000007;
template <typename T>
ostream& operator<<(ostream& out, pair<T, T>& a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T>
istream& operator>>(istream& in, pair<T, T>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<pair<T, T> > a) {
  for (int i = 0; i < a.size(); ++i) out << a[i] << endl;
  return out;
}
template <typename T>
istream& operator>>(istream& in, vector<T>& a) {
  for (int i = 0; i < a.size(); ++i) in >> a[i];
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> a) {
  for (int i = 0; i < a.size(); ++i)
    if (i == a.size() - 1)
      out << a[i];
    else
      out << a[i] << " ";
  return out;
}
const int MAX_A = 3000001;
int lp[MAX_A];
vector<int> pr;
void findPrimes() {
  for (int i = 2; i < MAX_A; ++i) {
    if (!lp[i]) {
      lp[i] = i;
      pr.push_back(i);
    }
    for (int j = 0; j < pr.size() && pr[j] <= lp[i] && 1ll * pr[j] * i < MAX_A;
         ++j)
      lp[pr[j] * i] = pr[j];
  }
}
vector<pair<int, int> > fastFact(int x) {
  vector<pair<int, int> > res;
  while (x > 1) {
    if (res.empty() || lp[x] != res.back().first) {
      res.push_back(make_pair(lp[x], 1));
    } else
      res.back().second++;
    x /= lp[x];
  }
  return res;
}
int pow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
struct IN {
  bool any;
  operator bool() const { return any; }
} CIN;
inline IN& operator>>(IN& in, int& x) {
  x = 0, in.any = 0;
  char c;
  while ((c = getchar()) > 0) {
    if (c < 48 || c > 57)
      if (in.any)
        return in;
      else
        continue;
    in.any = 1, x = x * 10 + c - '0';
  }
  return in;
}
int main() {
  ios_base::sync_with_stdio(0);
  findPrimes();
  int n;
  CIN >> n;
  vector<int> a(n);
  for (int& i : a) CIN >> i;
  vector<int> cnt(3000001);
  for (int i = 0; i < n; ++i) cnt[a[i]]++;
  int m;
  CIN >> m;
  vector<pair<int, int> > q(m);
  for (int i = 0; i < m; ++i) CIN >> q[i].first, q[i].second = i;
  sort(q.begin(), q.end());
  int prev = 1;
  long long cur = 0;
  vector<long long> ans(m);
  vector<pair<int, int> > f;
  vector<int> p;
  for (int i = 0; i < m; ++i) {
    int pos = q[i].second;
    while (prev < q[i].first) {
      f = fastFact(prev);
      p.assign(f.size() + 1, 0);
      while (p.back() == 0) {
        int d1 = 1;
        for (int i = 0; i < f.size(); ++i) d1 *= pow(f[i].first, p[i]);
        int d2 = prev / d1;
        if (d1 == d2)
          cur += cnt[d1] * (cnt[d1] - 1);
        else
          cur += cnt[d1] * cnt[d2];
        int j = 0;
        while (j < f.size() && p[j] == f[j].second) p[j] = 0, j++;
        p[j]++;
      }
      prev++;
    }
    ans[pos] = cur;
  }
  if (0) cerr << ans << endl;
  for (int i = 0; i < m; ++i) printf("%I64d\n", n * 1ll * (n - 1) - ans[i]);
  if (0)
    cerr << fixed << setprecision(0)
         << "TIME = " << clock() / (long double)CLOCKS_PER_SEC * 1000 << "\n";
  return 0;
}
