import copy

BITS = 32

a = input().split(" ")
n = int(a[0])
q = int(a[1])

v = [int(i) for i in input().split(" ")]
cnt = [0 for i in range(BITS)]

for i in v:
	for j in range(BITS):
		if (1 << j) == i:
			cnt[j] += 1
			break

res = []
for lgmoorz in range(q):

	cv = int(input())
	rem = []
	for j in cnt:
		rem.append(j)
	ok = True
	ans = 0

	for i in range(BITS):

		if cv & (1 << i) == 0:
			continue

		# print("check",i)

		found = False
		for j in range(i, -1, -1):
			needed = 1 << (i - j)
			if rem[j] >= needed:
				found = True
				ans += needed
				rem[j] -= needed
				break

		if found == False:
			ok = False
			break
	
	if ok:
		res.append(ans)
	else:
		res.append(-1)

for j in res:
	print(j)
