#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:108777216")
using namespace std;
class Eratosthenes_Sieve {
 public:
  int ES_MAX_GEN;
  int *minimal_prime_divisor;
  int *all_primes, all_primes_len;

 public:
  Eratosthenes_Sieve(int GEN_TO_VALUE = 3 * 1024 * 1024) {
    ES_MAX_GEN = max(150, GEN_TO_VALUE);
    minimal_prime_divisor = new int[ES_MAX_GEN + 1];
    all_primes = new int[ES_MAX_GEN + 1];
    all_primes_len = 0;
    minimal_prime_divisor[0] = minimal_prime_divisor[1] = -1;
    for (int i = 2; i <= ES_MAX_GEN; i++) minimal_prime_divisor[i] = 0;
    for (int i = 2; i <= ES_MAX_GEN; i++) {
      if (minimal_prime_divisor[i] == 0) {
        minimal_prime_divisor[i] = i;
        all_primes[all_primes_len++] = i;
      }
      for (int j = 0;
           j < all_primes_len && all_primes[j] <= minimal_prime_divisor[i] &&
           i * all_primes[j] <= ES_MAX_GEN;
           j++)
        minimal_prime_divisor[i * all_primes[j]] = all_primes[j];
    }
  }
  ~Eratosthenes_Sieve() {
    if (minimal_prime_divisor != NULL) delete[] minimal_prime_divisor;
    if (all_primes != NULL) delete[] all_primes;
  }
} es;
int const MAX_N = 1024 * 1024 * 3;
int s[MAX_N];
struct pp {
  int P, index;
} ms[MAX_N];
long long ans[MAX_N], real_cnt[MAX_N];
int dv[256];
bool operator<(const pp &A, const pp &B) { return A.P < B.P; }
long long CCC = 0;
int FLFL = 0;
int flag[MAX_N];
void rec(int from, int len, int VAL, long long cur) {
  if (cur * cur > VAL) return;
  if (cur * cur == VAL) {
    if (flag[cur] != FLFL) CCC += real_cnt[cur] * (real_cnt[cur] - 1LL);
    flag[cur] = FLFL;
    return;
  }
  if (flag[cur] != FLFL) CCC += real_cnt[cur] * (real_cnt[VAL / cur]) * 2LL;
  flag[cur] = FLFL;
  if (from >= len) return;
  rec(from + 1, len, VAL, cur * dv[from]);
  rec(from + 1, len, VAL, cur);
}
long long calc_diap(long long bg, long long en) {
  en--;
  if (bg > en) return 0;
  CCC = 0;
  for (int ww = bg; ww <= en; ww++) {
    int v = ww;
    int dv_len = 0;
    while (v > 1) {
      dv[dv_len++] = es.minimal_prime_divisor[v];
      v /= dv[dv_len - 1];
    }
    FLFL++;
    rec(0, dv_len, ww, 1);
  }
  return CCC;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &s[i]);
    real_cnt[s[i]]++;
  }
  int qq;
  scanf("%d", &qq);
  for (int i = 0; i < qq; i++) {
    scanf("%d", &ms[i].P);
    ms[i].index = i;
  }
  sort(ms, ms + qq);
  long long tot = n * (n - 1LL);
  long long cnt = calc_diap(1, ms[0].P);
  ans[ms[0].index] = tot - cnt;
  for (int j = 1; j < qq; j++) {
    cnt += calc_diap(ms[j - 1].P, ms[j].P);
    ans[ms[j].index] = tot - cnt;
  }
  for (int j = 0; j < qq; j++) printf("%I64d\n", ans[j]);
  return 0;
}
