import java.io.PrintWriter fun main() { val (n, q) = readln().split(" ").map { it.toInt() } val a = readln().split(" ").map { it.toInt() } val s = Array(q) { readln().toInt() } val pList = (0 until n).map { it -> (1..a[it]).toList().let {P(it.size, it.sum().toLong(), it.toIntArray()) } } val wholeSum = pList.sumOf { it.sum } val out = PrintWriter(System.out) for(i in 0 until q) { if(s[i] > wholeSum) { out.println(-1) continue } var sum = 0L var sizeSum = 0 for(j in pList.indices) { val p = pList[j] sizeSum += p.size sum += p.sum if(sum == s[i].toLong()) { out.println(sizeSum) break } else if(sum > s[i]) { sizeSum -= p.size sum -= p.sum out.println(s[i] - sum + sizeSum) break } } } out.flush() } data class P( val size: Int, val sum: Long, val value: IntArray, )