#include <bits/stdc++.h>
using namespace std;
const int MN = 3000002;
int N, M;
vector<int> arr;
vector<long long int> chk;
vector<long long int> pre;
void get_pre() {
  pre = vector<long long int>(MN, 0);
  for (int i = 1; i < MN; i++) {
    if (!chk[i]) continue;
    int mul = 1;
    while (i * mul < MN) {
      if (mul == i)
        pre[i * mul] += chk[mul] * (chk[mul] - 1);
      else
        pre[i * mul] += chk[mul] * chk[i];
      mul++;
    }
  }
}
vector<long long int> psum;
void get_psum() {
  psum = vector<long long int>(MN, 0);
  for (int i = 1; i < MN; i++) {
    psum[i] = pre[i] + psum[i - 1];
  }
}
int main() {
  scanf("%d", &N);
  arr.resize(N);
  chk = vector<long long int>(MN, 0);
  for (int i = 0; i < N; i++) {
    scanf("%d", &arr[i]);
    chk[arr[i]]++;
  }
  get_pre();
  get_psum();
  scanf("%d", &M);
  for (int i = 0; i < M; i++) {
    int p;
    scanf("%d", &p);
    printf("%I64d\n", (long long int)N * (N - 1) - psum[p - 1]);
  }
}
