#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;
  while (x || !n) {
    T newX = x / 10;
    s[n++] = '0' + (x - newX * 10);
    x = newX;
  }
  for (int i = n; i < padding; ++i) {
    writeChar('0');
  }
  for (; n > 0; writeChar(s[--n])) {
  }
}
}  // namespace io
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, typename V_SQR, V MOD>
struct ModInt {
  template <typename T>
  inline static V fix(T v) {
    if (v < 0) {
      v += MOD;
    } else if (v >= MOD) {
      v -= MOD;
    } else {
      return v;
    }
    if (v < 0 || v >= MOD) {
      v %= MOD;
    } else {
      return v;
    }
    if (v < 0) {
      v += MOD;
    } else if (v >= MOD) {
      v -= MOD;
    }
    return v;
  }
  inline ModInt(V_SQR v = 0) { _v = fix(v); }
  inline void operator*=(const ModInt& o) {
    _v = fix(static_cast<V_SQR>(_v) * o._v);
  }
  inline ModInt inv() const {
    ModInt res = *this;
    res.invInline();
    return res;
  }
  inline void invInline() {
    V x0, x1;
    extGcd<V>(_v, MOD, x0, x1);
    _v = fix(x0);
  }
  template <typename E>
  inline ModInt exp(E e) const {
    if (e < 0) {
      return inv().exp(-e);
    }
    V_SQR res = 1, mul = _v;
    while (e) {
      if (e & 1) {
        res = res * mul % MOD;
      }
      e >>= 1;
      if (e) {
        mul = mul * mul % MOD;
      }
    }
    return res;
  }
  int _v;
};
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 PRIME, V ROOT>
struct NTTUtils {
  using _ModInt = ModInt<V, V_SQR, PRIME>;
  inline NTTUtils() { _quota = numeric_limits<uint64_t>::max() / PRIME; }
  inline static NTTUtils& instance() {
    static NTTUtils instance;
    return instance;
  }
  inline void initCapacity(int capacity) {
    if (_revs.size() >= capacity) {
      return;
    }
    int _rootPow = 1 << __builtin_ctz(PRIME - 1);
    int pow2 = nextPow2_32(max(capacity, 2));
    _revs.reserve(pow2);
    _roots.reserve(pow2);
    if (_revs.size() < 2) {
      _revs.resize(2);
      _revs[0] = 0;
      _revs[1] = 1;
      _roots.resize(2);
      _roots[0] = 0;
      _roots[1] = 1;
    }
    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);
    _ModInt root(ROOT);
    for (int i = oldPow2; i < pow2; i <<= 1) {
      V_SQR v = root.exp((_rootPow / i) >> 1)._v;
      for (int j = i; j < i << 1; j += 2) {
        _roots[j] = _roots[j >> 1];
        _roots[j | 1] = _roots[j] * v % PRIME;
      }
    }
  }
  inline void nttModInt(vector<_ModInt>& vs, bool inverse, int n = -1) {
    int pow2 = nextPow2_32(n < 0 ? vs.size() : n);
    static vector<V> vsI;
    vsI.resize(pow2);
    for (int i = 0; i < pow2; ++i) {
      vsI[i] = i < vs.size() ? vs[i]._v : 0;
    }
    ntt(vsI, inverse, pow2);
    if (vs.size() < pow2) {
      vs.resize(pow2);
    }
    for (int i = 0; i < pow2; ++i) {
      vs[i] = vsI[i];
    }
  }
  inline void ntt(vector<V>& vs, bool inverse, int n = -1) {
    int pow2 = nextPow2_32(n < 0 ? vs.size() : n);
    initCapacity(pow2);
    _expand(vs, pow2);
    if (inverse) {
      reverse(vs.begin() + 1, vs.begin() + pow2);
      V_SQR v = _ModInt(pow2).inv()._v;
      for (int i = 0; i < pow2; ++i) {
        vs[i] = vs[i] * v % PRIME;
      }
    }
    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; i < pow2; i += l << 1) {
        for (int j = 0; j < l; ++j) {
          V v = vs[i + j + l] * _roots[j + l] % PRIME;
          vs[i + j + l] = vs[i + j] + PRIME - v;
          if (vs[i + j + l] >= PRIME) {
            vs[i + j + l] -= PRIME;
          }
          vs[i + j] += v;
          if (vs[i + j] >= PRIME) {
            vs[i + j] -= PRIME;
          }
        }
      }
    }
  }
  inline void ntt2(vector<V>& vs, bool inverse, int n = -1) {
    int pow2 = nextPow2_32(n < 0 ? vs.size() : n);
    initCapacity(pow2);
    static vector<uint64_t> vs64;
    vs64.resize(pow2);
    int shift = __builtin_ctz(_revs.size()) - __builtin_ctz(pow2);
    if (inverse) {
      reverse(vs.begin() + 1, vs.begin() + pow2);
      V_SQR v = _ModInt(pow2).inv()._v;
      for (int i = 0; i < pow2; ++i) {
        vs64[i] = vs[_revs[i] >> shift] * v % PRIME;
      }
    } else {
      for (int i = 0; i < pow2; ++i) {
        vs64[i] = vs[_revs[i] >> shift];
      }
    }
    for (int l = 1, cnt = 0; l < pow2; l <<= 1, ++cnt) {
      for (int i = 0; i < pow2; i += l << 1) {
        for (int j = 0; j < l; ++j) {
          uint64_t v = vs64[i + j + l] * _roots[j + l] % PRIME;
          vs64[i + j + l] = PRIME - v + vs64[i + j];
          vs64[i + j] += v;
        }
      }
      if (cnt == _quota) {
        for (int i = (0); i < (pow2); ++i) {
          vs64[i] %= PRIME;
        }
        cnt = 0;
      }
    }
    if (vs.size() < pow2) {
      vs.resize(pow2);
    }
    for (int i = (0); i < (pow2); ++i) {
      vs[i] = vs64[i] % PRIME;
    }
  }
  template <typename T>
  inline void _expand(vector<T>& vs, int pow2) {
    int size = vs.size();
    vs.resize(pow2);
    for (size_t i = size; i < pow2; ++i) {
      vs[i] = 0;
    }
  }
  vector<int> _revs;
  vector<V_SQR> _roots;
  uint64_t _quota;
};
template <typename V, typename V_SQR, V PRIME, V ROOT>
struct NTTMulUtils {
  using _ModInt = ModInt<V, V_SQR, PRIME>;
  inline static NTTMulUtils& instance() {
    static NTTMulUtils instance;
    return instance;
  }
  inline void mulInlineModInt(vector<_ModInt>& xs, const vector<_ModInt>& ys,
                              bool cyclic) {
    if (xs.empty() || ys.empty()) {
      xs.resize(1);
      xs[0] = 0;
      return;
    }
    int pow2 = nextPow2_32(cyclic ? max(xs.size(), ys.size())
                                  : xs.size() + ys.size() - 1);
    auto& ntt = NTTUtils<V, V_SQR, PRIME, ROOT>::instance();
    ntt._expand(xs, pow2);
    ntt.nttModInt(xs, false, pow2);
    static vector<_ModInt> ys2;
    ys2.resize(pow2);
    for (int i = (0); i < (pow2); ++i) {
      if (i < static_cast<int>((ys).size())) {
        ys2[i] = ys[i];
      } else {
        ys2[i] = 0;
      }
    }
    ntt._expand(ys2, pow2);
    ntt.nttModInt(ys2, false, pow2);
    for (int i = 0; i < pow2; ++i) {
      xs[i] *= ys2[i];
    }
    ntt.nttModInt(xs, true, pow2);
    _shrinkModInt(xs);
  }
  inline void _shrinkModInt(vector<_ModInt>& vs) {
    for (; vs.size() > 1 && !vs.back()._v; vs.pop_back()) {
    }
  }
};
template <typename V, typename V_SQR, V PRIME, V ROOT>
struct NTTPolyModInt : public vector<ModInt<V, V_SQR, PRIME>> {
  inline void operator*=(const NTTPolyModInt& o) {
    NTTMulUtils<V, V_SQR, PRIME, ROOT>::instance().mulInlineModInt(*this, o,
                                                                   false);
  }
};
}  // namespace math
const int MAXM = (1000000 + 2) >> 1;
const int MOD = 7340033;
using V = int;
using V_SQR = int64_t;
int n, x, y, x1;
math::NTTPolyModInt<V, V_SQR, MOD, 5> xs, revXs;
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;
  }
  xs *= revXs;
  memset(answers, 0xFF, sizeof(answers));
  for (int i = x + 1, j = y + 1; i <= (x << 1) && j < MAXM; ++i, ++j) {
    if (i < xs.size() && xs[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;
}
