#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int maxval = 3e6 + 20, bufsz = 5e4;
ifstream tmp("couple_cover.in");
class ipstream {
  char buf[bufsz] = {}, *p = buf;
  const char* const ep = buf + bufsz;
  void adv() {
    ++p;
    if (p == ep) {
      cin.read(p = buf, bufsz);
    }
  }

 public:
  ipstream() { cin.read(buf, bufsz); }
  ipstream& operator>>(int& x) {
    for (; isspace(*p); adv())
      ;
    for (x = 0; isdigit(*p); adv()) {
      x = 10 * x + *p - '0';
    }
    return *this;
  }
} pin;
class opstream {
  char buf[bufsz + 500] = {}, *p = buf;
  const char* const ep = buf + bufsz;
  opstream& flush() {
    if (p >= ep) {
      cout.write(buf, p - buf);
      p = buf;
    }
    return *this;
  }

 public:
  opstream() {}
  ~opstream() { cout.write(buf, p - buf); }
  opstream& operator<<(const ll x) {
    p += sprintf(p, "%llu", x);
    return flush();
  }
  opstream& operator<<(const char ch) {
    *p++ = ch;
    return flush();
  }
} pout;
int main() {
  int n;
  pin >> n;
  static array<int, maxval> cnt = {}, ge = {};
  for (int i = 0, x; i < n; ++i) {
    pin >> x;
    ++cnt[x], ++ge[x];
  }
  for (int i = maxval - 2; i >= 0; --i) {
    ge[i] += ge[i + 1];
  }
  static array<ll, maxval> d = {};
  for (ll i = 1; i < maxval; ++i) {
    d[min<ll>(maxval - 1, i * i)] += (ll)(cnt[i] - 1) * cnt[i];
    ll j = i + 1;
    for (; i * j < maxval; ++j) {
      d[i * j] += 2ll * cnt[i] * cnt[j];
    }
    d[maxval - 1] += 2ll * cnt[i] * ge[j];
  }
  for (int i = maxval - 2; i > 0; --i) {
    d[i] += d[i + 1];
  }
  int q;
  pin >> q;
  for (int i = 0, x; i < q; ++i) {
    pin >> x;
    pout << d[x] << '\n';
  }
  return 0;
}
