#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long M = 1e9 + 7;
const long long maxn = 1e6 + 107;
const double pi = acos(-1.0);
const double eps = 0.0000000001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <typename T>
inline void pr2(T x, int k = 64) {
  long long i;
  for (i = 0; i < k; i++) fprintf(stderr, "%d", (x >> i) & 1);
  putchar(' ');
}
template <typename T>
inline void add_(T &A, int B, long long MOD = M) {
  A += B;
  (A >= MOD) && (A -= MOD);
}
template <typename T>
inline void mul_(T &A, long long B, long long MOD = M) {
  A = (A * B) % MOD;
}
template <typename T>
inline void mod_(T &A, long long MOD = M) {
  A %= MOD;
  A += MOD;
  A %= MOD;
}
template <typename T>
inline void max_(T &A, T B) {
  (A < B) && (A = B);
}
template <typename T>
inline void min_(T &A, T B) {
  (A > B) && (A = B);
}
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
inline long long powMM(long long a, long long b, long long mod = M) {
  long long ret = 1;
  for (; b; b >>= 1ll, a = a * a % mod)
    if (b & 1) ret = ret * a % mod;
  return ret;
}
int startTime;
void startTimer() { startTime = clock(); }
void printTimer() {
  fprintf(stderr, "/--- Time: %ld milliseconds ---/\n", clock() - startTime);
}
namespace NTT {
const int maxn = 1 << 20 | 7;
const long long MOD = 998244353;
const long long g = 3;
int wn[maxn], invwn[maxn];
long long mul(long long x, long long y) { return x * y % MOD; }
long long poww(long long a, long long b) {
  long long ret = 1;
  for (; b; b >>= 1ll, a = mul(a, a))
    if (b & 1) ret = mul(ret, a);
  return ret;
}
void initwn(int l) {
  static int len = 0;
  if (len == l) return;
  len = l;
  long long w = poww(g, (MOD - 1) / len);
  int i;
  long long invw = poww(w, MOD - 2);
  wn[0] = invwn[0] = 1;
  for (i = 1; i < len; i++) {
    wn[i] = mul(wn[i - 1], w);
    invwn[i] = mul(invw, invwn[i - 1]);
  }
}
void ntt(long long *A, int len, int inv) {
  int i, j, k;
  initwn(len);
  for (i = 1, j = len / 2; i < len - 1; i++) {
    if (i < j) swap(A[i], A[j]);
    k = len / 2;
    while (j >= k) j -= k, k /= 2;
    if (j < k) j += k;
  }
  for (i = 2; i <= len; i <<= 1) {
    for (j = 0; j < len; j += i) {
      for (k = j; k < (j + i / 2); k++) {
        long long a, b;
        a = A[k];
        if (inv == -1)
          b = mul(A[k + i / 2], invwn[(long long)(k - j) * len / i]);
        else
          b = mul(A[k + i / 2], wn[(long long)(k - j) * len / i]);
        A[k] = (a + b);
        (A[k] >= MOD) && (A[k] -= MOD);
        A[k + i / 2] = (a - b + MOD);
        (A[k + i / 2] >= MOD) && (A[k + i / 2] -= MOD);
      }
    }
  }
  if (inv == -1) {
    long long vn = poww(len, MOD - 2);
    for (i = 0; i < len; i++) A[i] = mul(A[i], vn);
  }
}
void mul(long long *A, long long *B, long long *C, int len) {
  int i;
  ntt(A, len, 1);
  ntt(B, len, 1);
  for (i = 0; i < len; i++) C[i] = mul(A[i], B[i]);
  ntt(C, len, -1);
}
void inv(long long *A, long long *B, int l) {
  static long long C[maxn];
  B[0] = poww(A[0], MOD - 2);
  B[1] = 0;
  for (int len = 2; len <= l; len <<= 1) {
    int i;
    fill(B + len, B + len + len, 0);
    copy(A, A + len, C);
    fill(C + len, C + len + len, 0);
    ntt(C, len * 2, 1);
    ntt(B, len * 2, 1);
    for (i = 0; i < len * 2; i++) B[i] = mul(B[i], (MOD + 2 - mul(C[i], B[i])));
    ntt(B, len * 2, -1);
    fill(B + len, B + len + len, 0);
  }
}
static long long A[maxn], B[maxn];
void multiply(long long *a, long long *b, long long *ans, int n, int m) {
  int len = 1, i;
  while (len < n + m - 1) len <<= 1;
  for (i = 0; i < n; i++) A[i] = a[i];
  for (i = n; i < len; i++) A[i] = 0;
  for (i = 0; i < m; i++) B[i] = b[i];
  for (i = m; i < len; i++) B[i] = 0;
  mul(A, B, ans, len);
}
}  // namespace NTT
long long A[maxn], B[maxn], C[maxn];
int ans[maxn];
int main() {
  int n, i, x, y;
  scanf("%d%d%d", &n, &x, &y);
  for (i = 1; i <= n + 1; i++) {
    int k;
    scanf("%d", &k);
    A[k] = 1;
    B[x - k] = 1;
  }
  NTT::multiply(A, B, C, x + 1, x + 1);
  for (i = 1; i <= 1000000; i++) ans[i] = -1;
  for (i = x + 1; i <= x + 1 + x; i++)
    if (C[i]) {
      int now = (i - x + y) * 2, j;
      for (j = now; j <= 1000000; j += now) ans[j] = now;
    }
  int q;
  scanf("%d", &q);
  for (i = 1; i <= q; i++) {
    int x;
    scanf("%d", &x);
    printf("%d ", ans[x]);
  }
}
