#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, q; cin >> n >> q; vector a(n); rep(i, n) cin >> a[i]; vector b; rep(i, n) { for (int x = 1; x <= a[i]; ++x) b.push_back(x); } vector sum(b.size() + 1); rep(i, b.size()) sum[i + 1] = sum[i] + b[i]; while (q--) { ll s; cin >> s; auto it = lower_bound(sum.begin(), sum.end(), s); if (it == sum.end()) { cout << -1 << '\n'; } else { cout << it - sum.begin() << '\n'; } } return 0; }