#include <bits/stdc++.h>
using namespace std;
using cd = complex<double>;
const double PI = acos(-1);
int reverse(int num, int lg_n) {
  int res = 0;
  for (int i = 0; i < lg_n; i++) {
    if (num & (1 << i)) res |= 1 << (lg_n - 1 - i);
  }
  return res;
}
void fft(vector<cd> &a, bool invert) {
  int n = a.size();
  int lg_n = 0;
  while ((1 << lg_n) < n) lg_n++;
  for (int i = 0; i < n; i++) {
    if (i < reverse(i, lg_n)) swap(a[i], a[reverse(i, lg_n)]);
  }
  for (int len = 2; len <= n; len <<= 1) {
    double ang = 2 * PI / len * (invert ? -1 : 1);
    cd wlen(cos(ang), sin(ang));
    for (int i = 0; i < n; i += len) {
      cd w(1);
      for (int j = 0; j < len / 2; j++) {
        cd 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 (cd &x : a) x /= n;
  }
}
vector<int> mult(vector<cd> &a, vector<cd> &b) {
  vector<cd> 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;
}
long long mdp[1000010];
void crive() {
  for (long long i = 2; i <= 1000000; i++) {
    if (mdp[i] == 0) {
      mdp[i] = i;
      for (long long j = i * i; j <= 1000000; j += i) {
        if (mdp[j] == 0) mdp[j] = i;
      }
    }
  }
}
vector<long long> div(int l) {
  vector<long long> ans = {1};
  int sz = 1;
  while (l > 1) {
    long long p = mdp[l];
    long long it = p;
    while (l % it == 0) {
      for (int j = 0; j < sz; j++) ans.push_back(it * ans[j]);
      it *= p;
    }
    it /= p;
    sz = ans.size();
    l /= it;
  }
  sort(ans.begin(), ans.end());
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  crive();
  long long n, x, y;
  cin >> n >> x >> y;
  vector<cd> a(x + 1), b(x + 1);
  for (int i = 0; i < n + 1; i++) {
    int num;
    cin >> num;
    a[x - num] = 1;
    b[num] = 1;
  }
  vector<int> c = mult(a, b);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int l;
    cin >> l;
    vector<long long> d = div(l);
    long long resp = -1;
    for (int i = d.size() - 1; i >= 0 && d[i] > 2 * y; i--) {
      long long u = d[i];
      if (u & 1) continue;
      if ((u - 2 * y) / 2 + x < c.size() && c[(u - 2 * y) / 2 + x])
        resp = u, i = -1;
    }
    cout << resp << ' ';
  }
  cout << endl;
}
