#include <bits/stdc++.h>
#pragma comment(linker, "stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long freq[3000005], mul[3000005], n, q, x;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = n; i--; ++freq[x]) cin >> x;
  for (int i = 1; i < 3000005; ++i)
    if (freq[i])
      for (int j = i; j < 3000005; j += i)
        mul[j] += freq[i] * (freq[j / i] - (i == j / i));
  for (int i = 1; i < 3000005; ++i) mul[i] += mul[i - 1];
  for (cin >> q; q--; cout << n * (n - 1) - mul[x - 1] << '\n') cin >> x;
}
