#include<bits/stdc++.h> using namespace std; map<int,int> ans; int a[50]; int trans(int num) { int ans=0; while(num>1) { num/=2; ans++; } return ans; } int main() { int n,q; scanf("%d%d",&n,&q); for(int i=1;i<=n;i++) { int tmp; scanf("%d",&tmp); //printf("%d ",trans(tmp)); ans[trans(tmp)]++; } while(q--) { int b; scanf("%d",&b); int tot=0; while(b) { a[tot++]=(b%2); b/=2; } int now=0; int res=0; for(int i=tot-1;i>=0;i--) { //printf("%d ",a[i]); now+=a[i]; if(ans[i]<now) { now-=ans[i]; res+=ans[i]; now=now*2; } else { res+=now; now=0; } } //printf(" "); if(now) printf("-1 "); else printf("%d ",res); } }