#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using mint = modint998244353; ll B[101010], S[101010]; int main() { int N, Q; cin >> N >> Q; int n = 0, p = 0; for (int i = 0; i < N; i++) { int a; cin >> a; n += a; for (int j = 1; j <= a; j++) { B[p++] = j; } } for (int i = 0; i <= n; i++) S[i + 1] = S[i] + B[i]; while (Q--) { ll s; cin >> s; int ok = n + 1, ng = -1; while (abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (S[mid] >= s) ok = mid; else ng = mid; } cout << (ok == n + 1 ? -1: ok) << endl; } return 0; }