#include <bits/stdc++.h>
using namespace std;
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
namespace math {
inline uint32_t nextPow2_32(uint32_t v) {
  if (!v) {
    return 1;
  }
  uint32_t res = 1U << (31 - __builtin_clz(v));
  return res == v ? res : res << 1;
}
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 void fixModInline(V& v, V mod) {
  slightFixModInline<V>(v, mod);
  if (v < 0 || mod <= v) {
    v %= mod;
    slightFixModInline<V>(v, mod);
  }
}
template <typename V = int>
inline V addMod(V a, V b, V mod) {
  V res = a;
  res += b;
  slightFixModInline<V>(res, mod);
  return res;
}
template <typename V = int32_t>
inline V fixMod(V v, V mod) {
  V res = v;
  fixModInline<V>(res, mod);
  return res;
}
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 EXP = int32_t,
          typename V_SQR = int64_t>
inline V expMod(V base, EXP exp, const V& mod) {
  V res = fixMod<V>(1, mod);
  for (; exp > 0; exp >>= 1) {
    if (exp & 1) {
      mulModInline<V, V_SQR>(res, base, mod);
    }
    mulModInline<V, V_SQR>(base, base, mod);
  }
  return res;
}
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 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 V mulMod(V a, V b, V mod) {
  mulModInline<V, V_SQR>(a, b, mod);
  return a;
}
template <typename V = int>
inline V subMod(V a, V b, V mod) {
  V res = a;
  if (res >= b) {
    res -= b;
  } else {
    res = mod - (b - res);
  }
  slightFixModInline<V>(res, mod);
  return res;
}
template <typename V = int, typename V_SQR = int64_t>
struct NTTUtils {
  inline NTTUtils(V mod, V root, int capacity = -1) {
    init(mod, root, capacity);
  }
  inline void init(V mod, V root, int capacity = -1) {
    _mod = mod;
    _root = root;
    _invRoot = invMod(root, mod);
    _rootPow = 1 << __builtin_ctz(mod - 1);
    if (capacity > 0) {
      capacity = nextPow2_32(capacity);
    }
    capacity = max(capacity, 2);
    _revs.reserve(capacity);
    _revs.resize(2);
    _revs[0] = 0;
    _revs[1] = 1;
    _roots.reserve(capacity | 1);
    _roots.resize(2);
    _roots[0] = 0;
    _roots[1] = 1;
    _initCapacity(capacity);
    _vs.reserve(capacity);
  }
  inline const vector<V>& mulModify(vector<V>& x, vector<V>& y) {
    int pow2 = nextPow2_32(max(static_cast<int>(x.size() + y.size()) - 1, 1));
    _fix(x);
    ntt(x, false, pow2);
    _fix(y);
    ntt(y, false, pow2);
    _vs.resize(pow2);
    for (int i = 0; i < pow2; ++i) {
      _vs[i] = mulMod<V, V_SQR>(x[i], y[i], _mod);
    }
    ntt(_vs, true, pow2);
    _shrink(_vs);
    return _vs;
  }
  inline void _fix(vector<V>& x) {
    for (size_t i = 0; i < x.size(); ++i) {
      fixModInline<V>(x[i], _mod);
    }
  }
  inline void _shrink(vector<V>& vs) {
    for (; vs.size() > 1 && !vs.back(); vs.pop_back()) {
    }
  }
  inline void ntt(vector<V>& vs, bool invert, int n = -1) {
    int pow2 = nextPow2_32(n < 0 ? vs.size() : n);
    _initCapacity(pow2);
    _expand(pow2, vs);
    int shift = __builtin_ctz(_revs.size()) - __builtin_ctz(pow2);
    for (int i = 0; i < pow2; ++i) {
      int j = _revs[i] >> shift;
      if (i < j) {
        swap(vs[i], vs[j]);
      }
    }
    for (int l = 1; l < pow2; l <<= 1) {
      for (int i = 0, l2 = l << 1; i < pow2; i += l2) {
        int step = invert ? -1 : 1;
        for (int j = 0, k = invert ? l2 : l; j < l; ++j, k += step) {
          V v = mulMod<V, V_SQR>(vs[i + j + l], _roots[k], _mod);
          if (invert && j) {
            v = fixMod<V>(_mod - v, _mod);
          }
          vs[i + j + l] = subMod<V>(vs[i + j], v, _mod);
          vs[i + j] = addMod<V>(vs[i + j], v, _mod);
        }
      }
    }
    if (invert) {
      int invPow2 = invMod<V>(pow2, _mod);
      for (int i = 0; i < pow2; ++i) {
        mulModInline<V, V_SQR>(vs[i], invPow2, _mod);
      }
    }
  }
  inline void _initCapacity(int pow2) {
    if (_revs.size() >= pow2) {
      return;
    }
    int oldPow2 = _revs.size(), lgN = __builtin_ctz(pow2);
    _revs.resize(pow2);
    for (int i = 0; i < pow2; ++i) {
      _revs[i] = (_revs[i >> 1] >> 1) + ((i & 1) << (lgN - 1));
    }
    _roots.resize(pow2 | 1);
    for (int i = oldPow2; i < pow2; i <<= 1) {
      V v = expMod<V, V_SQR>(_root, (_rootPow >> 1) / i, _mod),
        mul = mulMod<V, V_SQR>(v, v, _mod);
      for (int j = i; j < i << 1; j += 2) {
        _roots[j] = _roots[j >> 1];
        _roots[j | 1] = v;
        mulModInline<V, V_SQR>(v, mul, _mod);
      }
    }
    _roots[pow2] = _roots[pow2 >> 1];
  }
  inline void _expand(int pow2, vector<V>& vs) {
    for (size_t i = vs.size(); i < pow2; ++i) {
      vs.push_back(0);
    }
  }
  vector<V> _revs, _roots, _vs;
  V _mod, _root, _invRoot;
  int _rootPow;
};
}  // namespace math
const int MAXN = 200000 + 2;
const int MAXM = (1000000 + 2) >> 1;
int n, x, y, x1;
vector<int> xs, revXs;
math::NTTUtils<int, uint64_t> ntt(998244353, 31, MAXN << 1);
int answers[MAXM];
int main() {
  io::readInt(n);
  io::readInt(x);
  io::readInt(y);
  x1 = x + 1;
  xs.resize(x1);
  revXs.resize(x1);
  for (int i = 0; i <= n; ++i) {
    int v;
    io::readInt(v);
    xs[v] = 1;
    revXs[x - v] = 1;
  }
  const auto& delta = ntt.mulModify(xs, revXs);
  memset(answers, 0xFF, sizeof(answers));
  for (int i = x + 1, j = y + 1; i <= (x << 1) && j < MAXM; ++i, ++j) {
    if (i < delta.size() && delta[i] && j < MAXM) {
      for (int k = j; k < MAXM; k += j) {
        answers[k] = j << 1;
      }
    }
  }
  int q;
  io::readInt(q);
  for (int i = 0; i < q; ++i) {
    int x;
    io::readInt(x);
    io::writeInt(answers[x >> 1]);
    io::writeChar(i + 1 == q ? '\n' : ' ');
  }
}
