#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int M = 1e6 + 10;
int n, m, x, y, a[N], f[M];
bitset<N> ans, tmp;
int main() {
  scanf("%d%d%d", &n, &x, &y);
  for (int i = 1; i <= n + 1; i++) {
    scanf("%d", &a[i]);
    tmp.set(a[i]);
  }
  for (int i = 1; i <= n + 1; i++) {
    ans |= tmp >> a[i];
  }
  for (int i = 1; i <= x; i++)
    if (ans[i]) f[2 * (i + y)] = 2 * (i + y);
  for (int i = 1; i < M; i++)
    for (int j = i; j < M; j += i) f[j] = max(f[j], f[i]);
  scanf("%d", &m);
  while (m--) {
    scanf("%d", &x);
    if (f[x])
      printf("%d ", f[x]);
    else
      printf("-1 ");
  }
}
