#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, typename V_SQR, V MOD>
struct ModInt {
  template <typename T>
  inline static T slightFix(T v) {
    if (v < 0) {
      v += MOD;
    } else if (v >= MOD) {
      v -= MOD;
    }
    return v;
  }
  template <typename T>
  inline static V fix(T v) {
    if (v < 0 || v >= MOD) {
      v = slightFix(v);
    }
    if (v < 0 || v >= MOD) {
      v %= MOD;
    }
    if (v < 0 || v >= MOD) {
      v = slightFix(v);
    }
    return v;
  }
  inline ModInt(V v = 0) { _v = fix(v); }
  inline void operator=(V v) { _v = fix(v); }
  inline void operator+=(const ModInt& o) { _v = slightFix(_v + o._v); }
  inline void operator*=(const ModInt& o) {
    _v = fix(static_cast<V_SQR>(_v) * o._v);
  }
  inline void initMul(const ModInt& x, const ModInt& y) {
    _v = fix(static_cast<V_SQR>(x._v) * y._v);
  }
  inline void initSub(const ModInt& x, const ModInt& y) {
    _v = slightFix(x._v - y._v);
  }
  inline ModInt inv() const {
    V g = MOD, r = _v, x = 0, y = 1;
    while (r != 0) {
      V q = g / r;
      g %= r;
      swap(g, r);
      x -= q * y;
      swap(x, y);
    }
    return ModInt(x < 0 ? x + MOD : x);
  }
  template <typename E>
  inline ModInt pow(E e) const {
    if (e < 0) {
      return inv().pow(-e);
    }
    ModInt res = 1, mul = *this;
    while (e) {
      if (e & 1) {
        res *= mul;
      }
      e >>= 1;
      if (e) {
        mul *= mul;
      }
    }
    return res;
  }
  inline void flip() {
    if (MOD > 1) {
      _v = MOD - _v;
    }
  }
  int _v;
};
template <typename V, typename V_SQR, V MOD, V ROOT>
struct NTTUtilsFixMod {
  using _ModInt = ModInt<V, V_SQR, MOD>;
  inline NTTUtilsFixMod(int capacity = -1) { init(capacity); }
  inline void init(int capacity = -1) {
    _root = _ModInt(ROOT);
    _invRoot = _root.inv();
    _rootPow = 1 << __builtin_ctz(MOD - 1);
    if (capacity > 0) {
      capacity = nextPow2_32(capacity);
    }
    capacity = max(capacity, 2);
    _revs.reserve(capacity);
    _revs.clear();
    _revs.push_back(0);
    _revs.push_back(1);
    _roots.reserve(capacity | 1);
    _roots.clear();
    _roots.emplace_back(0);
    _roots.emplace_back(1);
    _roots.emplace_back(1);
    _initCapacity(capacity);
    _xs.reserve(capacity);
    _ys.reserve(capacity);
  }
  inline const vector<_ModInt>& mul(const vector<V>& x, const vector<V>& y) {
    int pow2 = nextPow2_32(max(static_cast<int>(x.size() + y.size()) - 1, 1));
    _xs.resize(pow2);
    for (size_t i = 0; i < pow2; ++i) {
      _xs[i] = i < x.size() ? x[i] : 0;
    }
    ntt(_xs, false, pow2);
    _ys.resize(pow2);
    for (size_t i = 0; i < pow2; ++i) {
      _ys[i] = i < y.size() ? y[i] : 0;
    }
    ntt(_ys, false, pow2);
    for (int i = 0; i < pow2; ++i) {
      _xs[i] *= _ys[i];
    }
    ntt(_xs, true, pow2);
    _shrink(_xs);
    return _xs;
  }
  inline void _shrink(vector<_ModInt>& vs) {
    for (; vs.size() > 1 && !vs.back()._v; vs.pop_back()) {
    }
  }
  inline void ntt(vector<_ModInt>& 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.initMul(vs[i + j + l], _roots[k]);
          if (invert && j) {
            _v.flip();
          }
          vs[i + j + l].initSub(vs[i + j], _v);
          vs[i + j] += _v;
        }
      }
    }
    if (invert) {
      _v = _ModInt(pow2).inv();
      for (int i = 0; i < pow2; ++i) {
        vs[i] *= _v;
      }
    }
  }
  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 = _root.pow((_rootPow / i) >> 1);
      for (int j = i; j < i << 1; j += 2) {
        _roots[j] = _roots[j >> 1];
        _roots[j | 1].initMul(_roots[j], _v);
      }
    }
    _roots[pow2] = _roots[pow2 >> 1];
  }
  inline void _expand(int pow2, vector<_ModInt>& vs) {
    for (size_t i = vs.size(); i < pow2; ++i) {
      vs.emplace_back(0);
    }
  }
  vector<int> _revs;
  vector<_ModInt> _roots;
  _ModInt _root, _invRoot, _v;
  int _rootPow;
  vector<_ModInt> _xs, _ys;
};
}  // namespace math
const int MAXN = 200000 + 2;
const int MAXM = (1000000 + 2) >> 1;
int n, x, y, x1;
vector<int> xs, revXs;
math::NTTUtilsFixMod<int, int64_t, 998244353, 31> ntt(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.mul(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]._v && 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' : ' ');
  }
  return 0;
}
