#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e6 + 10;
long long cnt[maxn];
long long k[maxn], sum[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    cnt[a]++;
  }
  for (int i = 1; i < maxn; i++) {
    if (cnt[i] == 0) continue;
    for (int j = 1; j * i < maxn; j++) {
      if (i == j) {
        k[i * j] += cnt[i] * (cnt[j] - 1);
      } else {
        k[i * j] += cnt[i] * cnt[j];
      }
    }
  }
  for (int i = 1; i < maxn; i++) {
    sum[i] += sum[i - 1] + k[i];
  }
  int m;
  long long tmp = (long long)n * (n - 1);
  scanf("%d", &m);
  while (m--) {
    int p;
    scanf("%d", &p);
    printf("%I64d\n", tmp - sum[p - 1]);
  }
}
