#include <bits/stdc++.h>
using namespace std;
const int nn = 1100000;
const int inff = 0x3fffffff;
const double eps = 1e-8;
const double pi = acos(-1.0);
struct Complex {
  double r, i;
  Complex() {}
  Complex(double r, double i) : r(r), i(i) {}
  inline void real(const double& x) { r = x; }
  inline double real() { return r; }
  inline Complex operator+(const Complex& rhs) const {
    return Complex(r + rhs.r, i + rhs.i);
  }
  inline Complex operator-(const Complex& rhs) const {
    return Complex(r - rhs.r, i - rhs.i);
  }
  inline Complex operator*(const Complex& rhs) const {
    return Complex(r * rhs.r - i * rhs.i, r * rhs.i + i * rhs.r);
  }
  inline void operator/=(const double& x) { r /= x, i /= x; }
  inline void operator*=(const Complex& rhs) {
    *this = Complex(r * rhs.r - i * rhs.i, r * rhs.i + i * rhs.r);
  }
  inline void operator+=(const Complex& rhs) { r += rhs.r, i += rhs.i; }
  inline Complex conj() { return Complex(r, -i); }
};
void FFT(Complex* a, int n, int inverse) {
  static Complex b[nn];
  for (int i = 0; i < n; i++) {
    int index = 0;
    int cnt = n >> 1, x = i;
    while (cnt) {
      cnt >>= 1;
      index = (index << 1) + (x & 1);
      x >>= 1;
    }
    b[i] = a[index];
  }
  copy(b, b + n, a);
  for (int l = 2; l <= n; l <<= 1) {
    int mid = l >> 1;
    double p0 = pi * inverse / mid;
    Complex unit(cos(p0), sin(p0));
    for (int i = 0; i < n; i += l) {
      Complex temp(1.0, 0);
      for (int j = 0; j < mid; j++) {
        Complex w = temp * a[i + j + mid];
        a[i + j + mid] = a[i + j] - w;
        a[i + j] = a[i + j] + w;
        temp *= unit;
      }
    }
  }
}
Complex a1[nn], a2[nn];
int c[nn];
int main() {
  int n, x, y;
  scanf("%d%d%d", &n, &x, &y);
  int val;
  memset(c, -1, sizeof(c));
  for (int i = 0; i <= n; i++) {
    scanf("%d", &val);
    a1[val] = Complex(1.0, 0);
    a2[x - val] = Complex(1.0, 0);
  }
  FFT(a1, 1 << 19, 1);
  FFT(a2, 1 << 19, 1);
  for (int i = 0; i < (1 << 19); i++) {
    a1[i] = a1[i] * a2[i];
  }
  FFT(a1, 1 << 19, -1);
  for (int i = 0; i < (1 << 19); i++) a1[i] /= (1 << 19);
  for (int i = x + 1; i < (1 << 19); i++) {
    if (a1[i].real() > 0.5) {
      c[i - x + y] = i - x + y;
      for (int j = 2 * (i - x + y); j < (1 << 19); j += (i - x + y)) {
        c[j] = i - x + y;
      }
    }
  }
  int q;
  scanf("%d", &q);
  int l;
  while (q--) {
    scanf("%d", &l);
    if (c[l / 2] == -1) {
      printf("-1 ");
    } else {
      printf("%d ", 2 * c[l / 2]);
    }
  }
  printf("\n");
  return 0;
}
