#include <bits/stdc++.h>
using namespace std;
;
long long read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int maxn = 3e6 + 5;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3f;
int a[maxn];
long long num[maxn];
long long sum[maxn];
int p[maxn];
int main() {
  int n;
  int maxx = -1;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    num[a[i]]++;
  }
  for (int i = 0; i <= 3000000; i++) {
    for (int j = 0; j <= 3000000; j++) {
      if (i * j > 3000000) break;
      if (i == j) sum[i * j] -= num[i];
      sum[i * j] += num[i] * num[j];
    }
  }
  for (int i = 1; i <= 3000000; i++) {
    sum[i] += sum[i - 1];
  }
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &p[i]);
    printf("%lld\n", (long long)(n - 1) * n - sum[p[i] - 1]);
  }
  return 0;
}
