#include <bits/stdc++.h>
using namespace std;
const long long MaxLog = 32;
long long n, q;
long long pot[MaxLog];
long long h[MaxLog], v[MaxLog];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  pot[0] = 1LL;
  for (int i = 1; i < MaxLog; i++) {
    pot[i] = pot[i - 1] * 2LL;
  }
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    long long x;
    cin >> x;
    for (int j = 0; j < MaxLog; j++) {
      if (x == pot[j]) {
        h[j]++;
        break;
      }
    }
  }
  while (q--) {
    long long x;
    cin >> x;
    int d = 0;
    for (int i = 0; i < MaxLog; i++) {
      if ((x & (1LL << i))) {
        d = max(d, i);
      }
    }
    bool ok = true;
    int p = d;
    long long sum = 0;
    for (int i = 0; i < MaxLog; i++) {
      v[i] = h[i];
    }
    while (d >= 0) {
      if ((x & (1LL << d))) {
        while (p > d) p--;
        while (p >= 0 && v[p] < pot[d - p]) p--;
        if (p < 0) {
          ok = false;
          break;
        } else {
          v[p] -= pot[d - p];
          sum += pot[d - p];
        }
        d--;
      } else
        d--;
    }
    if (!ok) {
      cout << "-1\n";
    } else {
      cout << sum << "\n";
    }
  }
}
