#include <bits/stdc++.h>
using namespace std;
bool compare(int a, int b) { return a > b; }
int main() {
  int n, q1, q, a[20010], p[20010], sum = 0;
  cin >> n >> q1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n, compare);
  for (int i = 0; i < q1; i++) {
    cin >> q;
    for (int i = 0; i < n; i++) {
      if (q - a[i] > 0) {
        q -= a[i];
        sum++;
      } else if (q - a[i] == 0) {
        sum++;
        break;
      } else {
        continue;
      }
    }
    cout << sum << endl;
  }
  for (int i = 0; i < n; i++) {
    if (q - a[i] > 0) {
      q -= a[i];
      sum++;
    } else if (q - a[i] == 0) {
      sum++;
      break;
    } else {
      continue;
    }
  }
  cout << sum << endl;
}
