using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text; //using static CompLib.CompLib; //using DataStructure; namespace atcoder { class Program { const int intMax = 1000000000; const long longMax = 2000000000000000000; static void Main(string[] args) { var NQ = Console.ReadLine().Split().Select(int.Parse).ToArray(); var A = Console.ReadLine().Split().Select(int.Parse).ToArray(); var P = new long[(NQ[0] * (NQ[0] + 1)) / 2]; int idx = 0; for (int i = 1; i <= NQ[0]; i++) { int temp = 0; for (int j = 0; j < i; j++) { P[idx] = A[temp]; idx++; temp++; } } var sum = new long[P.Length + 1]; for (int i = 1; i <= P.Length; i++) { sum[i] = sum[i - 1] + P[i - 1]; } while (NQ[1]-- > 0) { int S = int.Parse(Console.ReadLine()); int l = 0; int r = P.Length; while (r - l > 1) { int mid = (l + r) / 2; if (sum[mid] >= S) { r = mid; } else { l = mid; } } if (sum[r] < S) Console.WriteLine(-1); else Console.WriteLine(r); } } } }