#include <bits/stdc++.h>
using namespace std;
int const MAXN = 5000;
int n, k, A[MAXN];
unordered_map<long long int, long long int> M;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int l = 1; l <= n; l++) {
    long long int sum = 0;
    for (int i = 0; i < l; i++) sum += A[i];
    if (M.find(sum) == M.end())
      M[sum] = l;
    else {
      int pre = M[sum];
      pre = min(pre, l);
      M[sum] = pre;
    }
    for (int j = 0; j < n - l; j++) {
      sum += A[j + l];
      sum -= A[j];
      if (M.find(sum) == M.end())
        M[sum] = l;
      else {
        int pre = M[sum];
        pre = min(pre, l);
        M[sum] = pre;
      }
    }
  }
  for (int i = 0; i < k; i++) {
    int tmp;
    cin >> tmp;
    if (tmp == 0)
      cout << 0;
    else if (M.find(tmp) == M.end())
      cout << -1;
    else
      cout << M[tmp];
    cout << " ";
  }
}
