N,Q = map(int,input().split()) a = list(map(int,input().split())) c = [] for i in range(N): c.append(a[i]*(a[i]+1)//2) for _ in range(Q): s = int(input()) sum_b = 0 ANS = 0 for i in range(N): if sum_b+c[i] < s: sum_b += c[i] ANS += a[i] elif sum_b < s: for j in range(a[i]): ANS += 1 sum_b += j+1 if sum_b >= s: break if sum_b < s: print(-1) else: print(ANS)