#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
vector<int> a, b;
int n, A[maxn], x, y, m, B[maxn], is[maxn];
inline int read() {
  char ch = getchar();
  int u = 0, f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    u = u * 10 + ch - 48;
    ch = getchar();
  }
  return u * f;
}
namespace polynomial {
const int maxn = ::maxn << 2;
const int P = 998244353;
inline int ksm(int x, int k, int rnt = 1) {
  for (int i = k; i; i >>= 1, x = 1ll * x * x % P)
    if (i & 1) rnt = 1ll * rnt * x % P;
  return rnt;
}
const int G = 3, invG = (ksm(G, P - 2));
int rev[maxn], H[maxn], E[maxn], invs, s, l;
inline void init(int n) {
  s = 2;
  l = 1;
  while (s < n) s <<= 1, l++;
  invs = (ksm(s, P - 2));
  for (int i = 0; i <= s - 1; ++i) rev[i] = rev[i >> 1] >> 1 | (i & 1) << l - 1;
  fill(E, E + n, 0);
  fill(H, H + n, 0);
}
inline void dft(int *a, int n, int f) {
  for (int i = 0; i <= n - 1; ++i)
    if (i < rev[i]) swap(a[i], a[rev[i]]);
  for (int i = 1; i < n; i <<= 1) {
    int Wn = ksm(f, (P - 1) / (i << 1));
    for (int j = 0; j < n; j += (i << 1)) {
      int w = 1;
      for (int k = 0; k < i; ++k, w = 1ll * w * Wn % P) {
        int A1 = a[j + k], A2 = 1ll * a[j + k + i] * w % P;
        a[j + k] = ((A1) + (A2) >= P ? (A1) + (A2)-P : (A1) + (A2));
        a[j + k + i] = ((A1) - (A2) < 0 ? (A1) - (A2) + P : (A1) - (A2));
      }
    }
  }
  if (f ^ G)
    for (int i = 0; i <= s - 1; ++i) a[i] = 1ll * a[i] * invs % P;
}
inline void conv(const vector<int> &a, const vector<int> &b, vector<int> &c,
                 int n) {
  if (!((int)a.size()) || !((int)b.size())) return;
  init(((int)a.size()) + ((int)b.size()) - 1);
  for (int i = 0; i <= ((int)a.size()) - 1; ++i) E[i] = a[i];
  for (int i = 0; i <= ((int)b.size()) - 1; ++i) H[i] = b[i];
  dft(E, s, G);
  dft(H, s, G);
  for (int i = 0; i <= s - 1; ++i) E[i] = 1ll * E[i] * H[i] % P;
  dft(E, s, invG);
  c = vector<int>(E, E + n);
}
}  // namespace polynomial
int main() {
  n = read();
  x = read();
  y = read();
  for (int i = 1; i <= n + 1; ++i) {
    int c = read();
    A[c]++, B[x - c]++;
  }
  for (int i = 0; i <= x; ++i) a.push_back(A[i]), b.push_back(B[i]);
  polynomial ::conv(a, b, a, x + x + 1);
  for (int i = x; i <= x + x; ++i)
    if (a[i]) is[i - x] = 1;
  m = read();
  for (int _ = 1; _ <= m; ++_) {
    int c = read(), ans = 0, d;
    if (c & 1) {
      printf("-1 ");
      continue;
    }
    c /= 2;
    for (int i = 1; i * i <= c; i++)
      if (c % i == 0) {
        d = c / i;
        if (i - y <= x && i > y && is[i - y]) ans = i;
        if (d - y <= x && d > y && is[d - y]) {
          ans = d;
          break;
        }
      }
    if (ans)
      printf("%d ", ans * 2);
    else
      printf("-1 ");
  }
  return 0;
}
