from bisect import bisect_left, bisect_right from itertools import accumulate import sys def printe(*args, end="\n", **kwargs): print(*args, end=end, file=sys.stderr, **kwargs) def main(): N, Q = map(int, input().split()) A = list(map(int, input().split())) A_accum = list(accumulate(A)) B_partial = [a_elm * (a_elm + 1) // 2 for a_elm in A] B_partial_accum = list(accumulate(B_partial, initial=0)) printe(B_partial_accum) printe(A_accum) for _ in range(Q): S = int(input()) b_p_idx = bisect_right(B_partial_accum, S) if b_p_idx == len(B_partial_accum): print(-1) continue if B_partial_accum[b_p_idx - 1] == S: print(A_accum[b_p_idx - 2]) continue min_a_idx = 0 max_a_idx = A[b_p_idx - 1] while max_a_idx - min_a_idx > 1: mid_a_idx = (max_a_idx + min_a_idx) // 2 if (1 + mid_a_idx) * (mid_a_idx) // 2 + \ B_partial_accum[b_p_idx - 1] >= S: max_a_idx = mid_a_idx else: min_a_idx = mid_a_idx print(A_accum[b_p_idx - 2] + max_a_idx) if __name__ == "__main__": main()