#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 3e6;
int cnt[MAXN + 1];
ll cnt_area[MAXN + 1];
int main() {
  int n;
  scanf("%d", &n);
  for (int _ = (0); _ < (n); ++_) {
    int a;
    scanf("%d", &a);
    cnt[a]++;
  }
  for (int i = (1); i < (1800); ++i) {
    if (cnt[i] == 0) continue;
    cnt_area[i * i] += (ll)cnt[i] * (cnt[i] - 1);
    for (int j = i + 1; i * j <= MAXN; j++)
      cnt_area[i * j] += 2 * (ll)cnt[i] * cnt[j];
  }
  partial_sum(begin(cnt_area), end(cnt_area), begin(cnt_area));
  int m;
  cin >> m;
  ll res = (ll)n * (n - 1);
  while (m--) {
    int p;
    scanf("%d", &p);
    printf("%lld\n", res - cnt_area[p - 1]);
  }
  return 0;
}
