#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
typedef long long ll;
using namespace std;
int main(){
ll num, q;
cin >> num >> q;
ll n = log2(2 * num - 1);
n = pow(2, n);
vector<ll> tree(2 * n, 0);
for(int i = 0; i < num; i++){
cin >> tree[i + n];
}
for(int i = n - 1; i >= 0; i--){
ll k = i;
while(k > 0){
tree[k] = max(tree[2 * k], tree[2 * k + 1]);
k /= 2;
}
}
while(q--){
int group, i = 1;
cin >> group;
if(tree[1] < group)cout << 0 << " ";
else{
while(i < tree.size()/2){
if(tree[2 * i] >= group)i = 2*i;
else if(tree[2 * i + 1] >= group)i = 2 * i + 1;
else break;
}
cout<<i - n + 1<<" ";
tree[i] -= group;
while(i > 0){
i /= 2;
tree[i] = max(tree[2 * i], tree[2 * i + 1]);
}
}
}
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHZlY3Rvcj4KI2luY2x1ZGU8YWxnb3JpdGhtPgojaW5jbHVkZTxjbWF0aD4KdHlwZWRlZiBsb25nIGxvbmcgbGw7CiAKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKIAppbnQgbWFpbigpewogICAgbGwgbnVtLCBxOwogICAgY2luID4+IG51bSA+PiBxOwogICAgbGwgbiA9IGxvZzIoMiAqIG51bSAtIDEpOwogICAgbiA9IHBvdygyLCBuKTsKICAgIHZlY3RvcjxsbD4gdHJlZSgyICogbiwgMCk7CiAKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBudW07IGkrKyl7CiAgICAgICAgY2luID4+IHRyZWVbaSArIG5dOyAgIAogICAgfQogCiAgICBmb3IoaW50IGkgPSBuIC0gMTsgaSA+PSAwOyBpLS0pewogICAgICAgIGxsIGsgPSBpOwogICAgICAgIHdoaWxlKGsgPiAwKXsKICAgICAgICAgICAgdHJlZVtrXSA9IG1heCh0cmVlWzIgKiBrXSwgdHJlZVsyICogayArIDFdKTsKICAgICAgICAgICAgayAvPSAyOwogICAgICAgIH0KICAgIH0KIAogICAgd2hpbGUocS0tKXsKICAgICAgICBpbnQgZ3JvdXAsIGkgPSAxOwogICAgICAgIGNpbiA+PiBncm91cDsKICAgICAgICBpZih0cmVlWzFdIDwgZ3JvdXApY291dCA8PCAwIDw8ICIgIjsKICAgICAgICBlbHNlewogICAgICAgICAgICB3aGlsZShpIDwgdHJlZS5zaXplKCkvMil7CiAgICAgICAgICAgICAgICBpZih0cmVlWzIgKiBpXSA+PSBncm91cClpID0gMippOwogICAgICAgICAgICAgICAgZWxzZSBpZih0cmVlWzIgKiBpICsgMV0gPj0gZ3JvdXApaSA9IDIgKiBpICsgMTsKICAgICAgICAgICAgICAgIGVsc2UgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY291dDw8aSAtIG4gKyAxPDwiICI7CiAgICAgICAgICAgIHRyZWVbaV0gLT0gZ3JvdXA7CiAgICAgICAgICAgIHdoaWxlKGkgPiAwKXsKICAgICAgICAgICAgICAgIGkgLz0gMjsKICAgICAgICAgICAgICAgIHRyZWVbaV0gPSBtYXgodHJlZVsyICogaV0sIHRyZWVbMiAqIGkgKyAxXSk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9Cn0=