#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops", "omit-frame-pointer", "inline")
#pragma GCC option("arch=native", "tune=native", "no-zero-upper")
#pragma GCC target("avx2")
using namespace std;
template <typename T>
void maxtt(T& t1, T t2) {
  t1 = max(t1, t2);
}
template <typename T>
void mintt(T& t1, T t2) {
  t1 = min(t1, t2);
}
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
const long long MOD2 = (long long)1000000007 * (long long)1000000007;
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int& x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
  assert(x >= 0 && x < mod);
}
void et(int x = -1) {
  printf("%d\n", x);
  exit(0);
}
long long fastPow(long long x, long long y, int mod = 1000000007) {
  long long ans = 1;
  while (y > 0) {
    if (y & 1) ans = (x * ans) % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }
void FFT(vector<complex<long double>>& A, int N, bool inv) {
  int n, t, i, j;
  for (n = 0;; n++)
    if (N == (1 << n)) break;
  for (int(mask) = 0; (mask) < (int)(N); (mask)++) {
    int mask2 = 0;
    for (int(i) = 0; (i) < (int)(n); (i)++)
      if (mask & (1 << i)) mask2 |= (1 << (n - 1 - i));
    if (mask < mask2) swap(A[mask], A[mask2]);
  }
  for (t = 1; t < N; t *= 2) {
    double theta = acos(-1) / t;
    complex<long double> w = {cos(theta), sin(theta)};
    if (inv) w.imag(-1 * w.imag());
    for (i = 0; i < N; i += 2 * t) {
      complex<long double> power = {1.0, 0.0};
      for (int(j) = 0; (j) < (int)(t); (j)++) {
        complex<long double> tmp1 = A[i + j] + A[i + t + j] * power;
        complex<long double> tmp2 = A[i + j] - A[i + t + j] * power;
        A[i + j] = tmp1;
        A[i + t + j] = tmp2;
        power = power * w;
      }
    }
  }
  if (inv)
    for (int(i) = 0; (i) < (int)(N); (i)++) {
      A[i].real(A[i].real() / N);
      A[i].imag(A[i].imag() / N);
    }
}
int a[(500135)];
vector<int> ps[(500135)];
void init() {
  for (int i = 1; i < (500135); i++) {
    for (int j = i; j < (500135); j += i) ps[j].push_back(i);
  }
}
void fmain(int tid) {
  int x, y;
  scanf("%d%d%d", &n, &x, &y);
  for (int(i) = 0; (i) < (int)(n + 1); (i)++) scanf("%d", a + i);
  int N = 1;
  while (N < x + 1) N *= 2;
  N *= 2;
  vector<complex<long double>> A(N, {0, 0});
  for (int(i) = 0; (i) < (int)(n + 1); (i)++) A[a[i]].real(1);
  FFT(A, N, false);
  vector<complex<long double>> B(N, {0, 0});
  for (int(i) = 0; (i) < (int)(n + 1); (i)++) B[x - a[i]].real(1);
  FFT(B, N, false);
  for (int(i) = 0; (i) < (int)(N); (i)++) A[i] = A[i] * B[i];
  FFT(A, N, true);
  vector<bool> z(N, 0);
  for (int(i) = 0; (i) < (int)(z.size()); (i)++) {
    z[i] = (long long)(A[i].real() + 0.5) > 0;
  }
  int Q;
  scanf("%d", &Q);
  init();
  for (int(i) = 1; (i) <= (int)(Q); (i)++) {
    int qx;
    scanf("%d", &qx);
    qx >>= 1;
    int nn = ps[qx].size();
    int ans = -1;
    for (int j = nn - 1; j >= 0; j--) {
      int P = ps[qx][j];
      if (P <= y) break;
      int tar = P + x - y;
      if (tar >= 0 && tar < N && z[tar]) {
        ans = P + P;
        break;
      }
    }
    printf("%d ", ans);
  }
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
