#include <bits/stdc++.h>
using namespace std;
template <class C>
void mini(C& a, C b) {
  a = min(a, b);
}
template <class C>
void maxi(C& a, C b) {
  a = max(a, b);
}
const double PI = acos(-1);
void fft(vector<complex<double> >& a, bool invert) {
  int n = a.size();
  for (int i = 1, j = 0; i < n; i++) {
    int bit = n >> 1;
    for (; j & bit; bit >>= 1) j ^= bit;
    j ^= bit;
    if (i < j) swap(a[i], a[j]);
  }
  for (int len = 2; len <= n; len <<= 1) {
    double ang = 2 * PI / len * (invert ? -1 : 1);
    complex<double> wlen(cos(ang), sin(ang));
    for (int i = 0; i < n; i += len) {
      complex<double> w(1);
      for (int j = 0; j < len / 2; j++) {
        complex<double> u = a[i + j], v = a[i + j + len / 2] * w;
        a[i + j] = u + v;
        a[i + j + len / 2] = u - v;
        w *= wlen;
      }
    }
  }
  if (invert) {
    for (complex<double>& x : a) x /= n;
  }
}
vector<int> multiply(vector<int> const& a, vector<int> const& b) {
  vector<complex<double> > fa(a.begin(), a.end()), fb(b.begin(), b.end());
  int n = 1;
  while (n < a.size() + b.size()) n <<= 1;
  fa.resize(n);
  fb.resize(n);
  fft(fa, false);
  fft(fb, false);
  for (int i = 0; i < n; i++) fa[i] *= fb[i];
  fft(fa, true);
  vector<int> result(n);
  for (int i = 0; i < n; i++) result[i] = round(fa[i].real());
  return result;
}
void a() {
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> a(400001);
  vector<int> b(400001);
  int aux;
  for (int i = 0; i < n + 1; i++) {
    cin >> aux;
    a[aux]++;
    b[200000 - aux]++;
  }
  a = multiply(a, b);
  vector<int> res(500001, -1);
  for (int d = 2; d <= 500000; d++) {
    int i = d - y + 200000;
    if (i <= 200000 or i >= a.size() or a[i] == 0) continue;
    int j = d;
    while (j < res.size()) {
      res[j] = 2 * d;
      j += d;
    }
  }
  int q;
  cin >> q;
  int l;
  while (q--) {
    cin >> l;
    l /= 2;
    cout << res[l] << ' ';
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  a();
  return 0;
}
