#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS = 1e-8;
const int INF = 0x3F3F3F3F;
const ll LINF = 4611686018427387903;
const int MOD = 1e9 + 7;
const int N = 2e5 + 25, C = 1e6 + 25;
vector<int> fac[C];
int ans[C];
void init() {
  for (int i = 2; i < C; i += 2)
    for (int j = i; j < C; j += i) fac[j].push_back(i);
}
bitset<N> dis, owo;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  init();
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> arr(n + 1);
  for (int i = 0; i <= n; i++) cin >> arr[i];
  for (int i = 1; i <= n; i++) {
    owo.set(0);
    dis |= (owo <<= arr[i] - arr[i - 1]);
  }
  int q;
  cin >> q;
  while (q--) {
    int l;
    cin >> l;
    if (ans[l]) {
      cout << ans[l] << ' ';
      continue;
    }
    int mx = -1;
    for (int a : fac[l]) {
      int w = a;
      a = (a >> 1) - y;
      if (a > 0 && a < N && dis[a]) mx = w;
    }
    cout << (ans[l] = mx) << ' ';
  }
  return 0;
}
