#include <bits/stdc++.h>
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define FA(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define pb push_back
#define mp make_pair
#define sz(a) (int)(a).size()
#define f first
#define s second
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define db long double
using namespace std ;
const int L =2e5+5 ;
ll T[L],ST[L] ; ll A[2005],ans[2005] ;
int N ;
set< pair<ll,int> > X ;
// struct comp{bool operator()(int x,int y){return A[x]<A[y];}};
void bs(ll l,ll r,vi &todo)
{
// cout<<"l = "<<l<<" r= "<<r<<" with elements "<<sz(todo)<<endl ;
if(l==r)
{
FN(i,sz(todo)) ans[todo[i]]=l ;
todo.clear() ;
return ;
}
ll m = (l+r)/2 ;
ll tot = 0 ;
FEN(i,N) tot += max(m-ST[i],(ll)0)/T[i] ;
vi Left,Right ;
FN(i,sz(todo))
{
if(A[todo[i]]<=tot) Left.pb(todo[i]) ;
else Right.pb(todo[i]) ;
}
todo.clear() ;
if(sz(Left)>0) bs(l,m,Left) ;
if(sz(Right)>0) bs(m+1,r,Right) ;
}
int main()
{
std::ios::sync_with_stdio(false);
int M ; cin>>N>>M ;
FEN(i,N) cin>>T[i] ;
sort(T+1,T+N+1) ;
ST[1]=0 ; X.insert(mp(T[1],1)) ;
for(int i=2;i<=N;++i)
{
ST[i] = X.begin()->f ;
int x = X.begin()->s ;
X.erase(X.begin()) ;
X.insert(mp(ST[i]+T[x],x)) ;
X.insert(mp(ST[i]+T[i],i)) ;
}
X.clear() ;
FEN(i,M) cin>>A[i] ;
vi todo ; FEN(i,M) todo.pb(i) ;
// sort(todo.begin(),todo.end(),comp) ;
bs(1,(ll)1e13+5,todo) ;
FEN(i,M) cout<<ans[i]<<endl ;
return 0 ;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgRk4oaSwgbikgZm9yIChpbnQgaSA9IDA7IGkgP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