#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma warning(disable : 4996)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
inline void accell() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(0);
}
void say(string s) {
  cout << s << endl;
  return;
}
template <class T>
ostream& operator<<(ostream& out, const pair<int, int>& X) {
  out << X.first << ' ' << X.second << endl;
  return out;
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& X) {
  for (const auto& it : X) out << it << ' ';
  return out;
}
template <class T>
ostream& operator<<(ostream& out, const set<T>& X) {
  for (const auto& it : X) out << it << ' ';
  return out;
}
template <class T>
void dbg(const T& X) {
  cerr << "DEBUG: "
       << ": ";
  cerr << X << endl;
}
const int MOD1 = 1e9 + 7;
const int N = 1e6 + 1;
const int MOD2 = 998244353;
const ll inf = 3e18;
const int mx = (1 << 19) - 1;
const int mod = 1e9 + 7;
const ull K = 2e5 + 1;
const ll mod2 = (ll)mod * (ll)mod;
vector<int> divs[N + 1];
signed main() {
  accell();
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> a(n + 1);
  for (int i = 0; i <= n; ++i) {
    cin >> a[i];
  }
  int q;
  cin >> q;
  vector<int> l(q);
  vector<bool> used(N + 1);
  for (int i = 0; i < q; ++i) {
    cin >> l[i];
    l[i] /= 2;
    if (!used[l[i]]) {
      for (int j = 1; j * j <= l[i]; ++j) {
        if (l[i] % j != 0) continue;
        divs[l[i]].push_back(j);
        divs[l[i]].push_back(l[i] / j);
      }
      sort(divs[l[i]].rbegin(), divs[l[i]].rend());
    }
    used[l[i]] = true;
  }
  bitset<K> an;
  bitset<K> hv;
  for (int i = n; i >= 0; --i) {
    hv[a[i]] = 1;
    an |= (hv >> a[i]);
  }
  vector<int> ans(N + 1);
  used.assign(N + 1, false);
  for (int i = 0; i < q; ++i) {
    if (used[l[i]]) {
      cout << ans[l[i]] << ' ';
      continue;
    }
    used[l[i]] = true;
    int ansx = 0;
    for (auto it : divs[l[i]]) {
      int cur = it - y;
      if (cur <= 2e5 && cur > 0 && an[cur] == 1) {
        ans[l[i]] = 2 * it;
        cout << 2 * it << ' ';
        break;
      }
    }
    if (ans[l[i]] == 0) {
      ans[l[i]] = -1;
      cout << -1 << ' ';
    }
  }
  return 0;
}
