#include int main() { int n, q, len = 0; scanf("%d%d", &n, &q); std::vector a(n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); len += a[i]; } std::vector c(len + 1); int idx = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < a[i]; j++) { c[idx] = j + 1; idx++; } } for (int i = 0; i < len; i++) { c[i + 1] += c[i]; } for (int i = 0; i < q; i++) { int s; scanf("%d", &s); auto it = lower_bound(c.begin(), c.end(), s); if (it == c.end()) { puts("-1"); } else { printf("%d\n", it - c.begin()); } } }