#include <bits/stdc++.h>
using namespace std;
const int N = 3e6 + 3;
long long PMT, p;
int n, m;
long long num[N], sum[N];
void show_sum() {
  for (int i = 0; i <= p; i++) {
    cout << "sum" << i << "=" << sum[i] << endl;
  }
}
void show_num(int t) {
  for (int i = 0; i <= t; i++) {
    cout << "num" << i << "=" << num[i] << endl;
  }
}
int main(int argc, char** argv) {
  int a, ma = 0;
  scanf("%d", &n);
  PMT = 1ll * n * (n - 1);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    if (ma < a) ma = a;
    num[a]++;
  }
  for (int i = 1; i <= ma; i++) {
    for (int j = 1; j <= ma; j++) {
      if (1ll * i * j > N) break;
      sum[i * j] += num[i] * num[j];
      if (i == j) sum[i * j] -= num[i];
    }
  }
  for (int j = 2; j <= N; j++) {
    sum[j] += sum[j - 1];
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%I64d", &p);
    printf("%I64d\n", PMT - sum[p - 1]);
  }
  return 0;
}
