#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T1, typename T2>
inline void chkmin(T1& x, const T2& y) {
  if (y < x) x = y;
}
template <typename T1, typename T2>
inline void chkmax(T1& x, const T2& y) {
  if (x < y) x = y;
}
int n, x, y;
vector<int> a;
void read() {
  cin >> n >> x >> y;
  a.resize(x + 1);
  for (int i = 0; i <= n; i++) {
    int have;
    cin >> have;
    a[have] = 1;
  }
}
const int LOG = 19;
const int N = 1 << LOG;
const int MAXN = N + 228;
using cd = complex<double>;
const ld PI = acos(-1);
int rev[MAXN];
cd w[MAXN];
void initFFT() {
  for (int i = 0; i < N; i++) {
    w[i] = cd(cos(2 * PI * i / N), sin(2 * PI * i / N));
  }
  rev[0] = 0;
  for (int mask = 1; mask < N; mask++) {
    rev[mask] = (rev[mask >> 1] >> 1) ^ ((mask & 1) << (LOG - 1));
  }
}
void FFT(cd* a) {
  for (int i = 0; i < N; i++) {
    if (i < rev[i]) {
      swap(a[i], a[rev[i]]);
    }
  }
  for (int l = 0; l < LOG; l++) {
    int len = 1 << l;
    for (int st = 0; st < N; st += len << 1) {
      for (int i = 0; i < len; i++) {
        cd x = a[st + i], y = a[st + i + len] * w[i << (LOG - 1 - l)];
        a[st + i] = x + y;
        a[st + i + len] = x - y;
      }
    }
  }
}
cd A[MAXN], B[MAXN];
vector<int> mul(vector<int> a, vector<int> b) {
  initFFT();
  for (int i = 0; i < (int)a.size(); i++) {
    A[i] = a[i];
  }
  for (int i = 0; i < (int)b.size(); i++) {
    B[i] = b[i];
  }
  FFT(A);
  FFT(B);
  for (int i = 0; i < N; i++) {
    A[i] *= B[i];
  }
  FFT(A);
  reverse(A + 1, A + N);
  vector<int> ans(N);
  for (int i = 0; i < N; i++) {
    ans[i] = (ll)(A[i].real() / N + 0.5);
  }
  return ans;
}
const int L = 1e6 + 10;
int ans[L];
void build() {
  vector<int> b = a;
  reverse((b).begin(), (b).end());
  auto fans = mul(a, b);
  fill(ans, ans + L, -1);
  for (int i = 1; i <= x; i++) {
    if (fans[x + i]) {
      ans[i * 2 + 2 * y] = i * 2 + 2 * y;
    }
  }
  for (int i = 1; i < L; i++) {
    for (int j = i; j < L; j += i) {
      chkmax(ans[j], ans[i]);
    }
  }
}
void run() {
  build();
  int q;
  cin >> q;
  while (q--) {
    int l;
    cin >> l;
    cout << ans[l] << " ";
  }
  cout << "\n";
}
void write() {}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20),
      cout.setf(ios::fixed);
  read();
  run();
  write();
  return 0;
}
