#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << '{';
  string sep;
  for (const auto& x : v) os << sep << x, sep = ", ";
  return os << '}';
}
template <typename T, size_t size>
ostream& operator<<(ostream& os, const array<T, size>& arr) {
  os << '{';
  string sep;
  for (const auto& x : arr) os << sep << x, sep = ", ";
  return os << '}';
}
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
namespace math {
template <typename V = int32_t>
inline V extGcd(V a, V b, V& x, V& y) {
  bool negativeA = false;
  if (a < 0) {
    negativeA = true;
    a = -a;
  }
  bool negativeB = false;
  if (b < 0) {
    negativeB = true;
    b = -b;
  }
  x = 1;
  y = 0;
  V xTmp = 0;
  V yTmp = 1;
  while (b) {
    V q = a / b;
    tie(x, xTmp) = make_tuple(xTmp, x - q * xTmp);
    tie(y, yTmp) = make_tuple(yTmp, y - q * yTmp);
    tie(a, b) = make_tuple(b, a - q * b);
  }
  if (negativeA) {
    x = -x;
  }
  if (negativeB) {
    y = -y;
  }
  return a;
}
template <typename V = int>
inline void slightFixModInline(V& v, const V& mod) {
  if (v < 0) {
    v += mod;
  }
  if (v >= mod) {
    v -= mod;
  }
}
template <typename V = int>
inline V invMod(V a, V mod) {
  V x0, x1, gcd = extGcd(a, mod, x0, x1);
  slightFixModInline(x0, mod);
  return x0;
}
template <typename V = int32_t, typename V_SQR = int64_t>
inline void mulModInline(V& res, V x, V mod) {
  if (!res || !x) {
    res = 0;
  } else if (res < mod / x) {
    res *= x;
  } else {
    res = static_cast<V_SQR>(res) * x % mod;
  }
}
template <typename V = int32_t, typename V_SQR = int64_t>
inline V mulMod(V a, V b, V mod) {
  mulModInline<V, V_SQR>(a, b, mod);
  return a;
}
}  // namespace math
template <const int& MOD>
struct _m_int {
  int val;
  _m_int(int64_t v = 0) {
    if (v < 0) v = v % MOD + MOD;
    if (v >= MOD) v %= MOD;
    val = int(v);
  }
  _m_int(uint64_t v) {
    if (v >= MOD) v %= MOD;
    val = int(v);
  }
  _m_int(int v) : _m_int(int64_t(v)) {}
  _m_int(unsigned v) : _m_int(uint64_t(v)) {}
  static int inv_mod(int a, int m = MOD) { return math::invMod(a, m); }
  explicit operator int() const { return val; }
  _m_int& operator+=(const _m_int& other) {
    val -= MOD - other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  _m_int& operator-=(const _m_int& other) {
    val -= other.val;
    if (val < 0) val += MOD;
    return *this;
  }
  static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
    return unsigned(x % MOD);
  }
  _m_int& operator*=(const _m_int& other) {
    val = math::mulMod(val, other.val, MOD);
    return *this;
  }
  _m_int& operator/=(const _m_int& other) { return *this *= other.inv(); }
  friend _m_int operator+(const _m_int& a, const _m_int& b) {
    return _m_int(a) += b;
  }
  friend _m_int operator-(const _m_int& a, const _m_int& b) {
    return _m_int(a) -= b;
  }
  friend _m_int operator*(const _m_int& a, const _m_int& b) {
    return _m_int(a) *= b;
  }
  _m_int& operator++() {
    val = val == MOD - 1 ? 0 : val + 1;
    return *this;
  }
  _m_int operator++(int) {
    _m_int before = *this;
    ++*this;
    return before;
  }
  friend bool operator==(const _m_int& a, const _m_int& b) {
    return a.val == b.val;
  }
  friend bool operator!=(const _m_int& a, const _m_int& b) {
    return a.val != b.val;
  }
  _m_int inv() const { return inv_mod(val); }
  _m_int pow(int64_t p) const {
    if (p < 0) return inv().pow(-p);
    _m_int a = *this, result = 1;
    while (p > 0) {
      if (p & 1) result *= a;
      p >>= 1;
      if (p > 0) a *= a;
    }
    return result;
  }
};
extern const int MOD = 998244353;
using mod_int = _m_int<MOD>;
template <const int& MOD>
struct NTT {
  using ntt_int = _m_int<MOD>;
  vector<ntt_int> roots = {0, 1};
  vector<int> bit_reverse;
  int max_size = -1;
  ntt_int root;
  void reset() {
    roots = {0, 1};
    max_size = -1;
  }
  static bool is_power_of_two(int n) { return (n & (n - 1)) == 0; }
  static int round_up_power_two(int n) {
    while (n & (n - 1)) n = (n | (n - 1)) + 1;
    return max(n, 1);
  }
  static int get_length(int n) {
    assert(is_power_of_two(n));
    return __builtin_ctz(n);
  }
  void bit_reorder(int n, vector<ntt_int>& values) {
    if (int(bit_reverse.size()) != n) {
      bit_reverse.assign(n, 0);
      int length = get_length(n);
      for (int i = 1; i < n; i++)
        bit_reverse[i] = (bit_reverse[i >> 1] >> 1) | ((i & 1) << (length - 1));
    }
    for (int i = 0; i < n; i++)
      if (i < bit_reverse[i]) swap(values[i], values[bit_reverse[i]]);
  }
  void find_root() {
    max_size = 1 << __builtin_ctz(MOD - 1);
    root = 2;
    while (!(root.pow(max_size) == 1 && root.pow(max_size / 2) != 1)) root++;
  }
  void prepare_roots(int n) {
    if (max_size < 0) find_root();
    assert(n <= max_size);
    if (int(roots.size()) >= n) return;
    int length = get_length(int(roots.size()));
    roots.resize(n);
    while (1 << length < n) {
      ntt_int z = root.pow(max_size >> (length + 1));
      for (int i = 1 << (length - 1); i < 1 << length; i++) {
        roots[2 * i] = roots[i];
        roots[2 * i + 1] = roots[i] * z;
      }
      length++;
    }
  }
  void fft_iterative(int n, vector<ntt_int>& values) {
    assert(is_power_of_two(n));
    prepare_roots(n);
    bit_reorder(n, values);
    for (int len = 1; len < n; len *= 2)
      for (int start = 0; start < n; start += 2 * len)
        for (int i = 0; i < len; i++) {
          ntt_int even = values[start + i];
          ntt_int odd = values[start + len + i] * roots[len + i];
          values[start + len + i] = even - odd;
          values[start + i] = even + odd;
        }
  }
  void invert_fft(int n, vector<ntt_int>& values) {
    ntt_int inv_n = ntt_int(n).inv();
    for (int i = 0; i < n; i++) values[i] *= inv_n;
    reverse(values.begin() + 1, values.end());
    fft_iterative(n, values);
  }
  const int FFT_CUTOFF = 150;
  template <typename T>
  vector<T> mod_multiply(const vector<T>& _left, const vector<T>& _right) {
    if (_left.empty() || _right.empty()) return {};
    vector<ntt_int> left(_left.begin(), _left.end());
    vector<ntt_int> right(_right.begin(), _right.end());
    int n = int(left.size());
    int m = int(right.size());
    int output_size = n + m - 1;
    int N = round_up_power_two(output_size);
    left.resize(N, 0);
    right.resize(N, 0);
    fft_iterative(N, left);
    fft_iterative(N, right);
    for (int i = 0; i < N; i++) left[i] *= right[i];
    invert_fft(N, left);
    return vector<T>(left.begin(), left.begin() + output_size);
  }
};
NTT<MOD> ntt;
const int L_MAX = 5e5 + 5;
namespace io {
const int _kReadBufferSize = 1 << 15;
char _readBuffer[_kReadBufferSize];
int _readPos;
int _readLength;
bool _ended = false;
inline void _loadBuffer() {
  _readLength = static_cast<int>(
      fread(_readBuffer, sizeof(char), _kReadBufferSize, stdin));
  _readPos = 0;
}
inline char readChar(bool advance = true) {
  if (_ended) {
    return 0;
  }
  if (_readPos >= _readLength) {
    _loadBuffer();
    if (_readLength == 0) {
      _ended = true;
      return 0;
    }
  }
  return _readBuffer[advance ? _readPos++ : _readPos];
}
template <typename T>
inline bool readInt(T& res) {
  char ch;
  while (true) {
    ch = readChar(false);
    if (!ch) {
      return false;
    }
    if (!isspace(ch)) {
      break;
    }
    ++_readPos;
  }
  ch = readChar(false);
  bool negative = ch == '-';
  if (negative) {
    ++_readPos;
  }
  res = 0;
  while (true) {
    ch = readChar(false);
    if (!isdigit(ch)) {
      break;
    }
    res = (res << 3) + (res << 1) + (ch & 15);
    ++_readPos;
  }
  if (negative) {
    res = -res;
  }
  return true;
}
const int _kWriteBufferSize = 1 << 15;
int _writePos = 0;
char _writeBuffer[_kWriteBufferSize];
inline void writeChar(char x) {
  if (_writePos == _kWriteBufferSize) {
    fwrite(_writeBuffer, 1, _kWriteBufferSize, stdout);
    _writePos = 0;
  }
  _writeBuffer[_writePos++] = x;
}
struct _Flusher {
  inline void flush() {
    if (_writePos) {
      fwrite(_writeBuffer, 1, _writePos, stdout);
      _writePos = 0;
    }
    fflush(stdout);
  }
  inline ~_Flusher() { flush(); }
} _flusher;
template <class T>
inline void writeInt(T x, int padding = 0) {
  static char s[32];
  if (x < 0) {
    writeChar('-');
    x = -x;
  }
  int n = 0;
  for (; x || !n; x /= 10) {
    s[n++] = '0' + x % 10;
  }
  for (int i = n; i < padding; ++i) {
    writeChar('0');
  }
  for (; n > 0; writeChar(s[--n])) {
  }
}
}  // namespace io
int main() {
  int N, X, Y;
  io::readInt(N);
  io::readInt(X);
  io::readInt(Y);
  vector<mod_int> lines(X + 1, 0);
  for (int i = 0; i <= N; i++) {
    int a;
    io::readInt(a);
    lines[a] = 1;
  }
  vector<mod_int> rev_lines = lines;
  reverse(rev_lines.begin(), rev_lines.end());
  vector<mod_int> product = ntt.mod_multiply(lines, rev_lines);
  vector<int> answers(L_MAX, -1);
  for (int f = Y + 1; f < L_MAX; f++)
    if (f - Y <= X && product[X + f - Y] != 0)
      for (int x = f; x < L_MAX; x += f) answers[x] = 2 * f;
  int Q;
  io::readInt(Q);
  for (int q = 0; q < Q; q++) {
    int len;
    io::readInt(len);
    len /= 2;
    io::writeInt(answers[len]);
    io::writeChar(q < Q - 1 ? ' ' : '\n');
  }
}
