
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
#define cout2(x, y) cout << x << " " << y << endl
#define N 200005

using namespace std;

int t[N];
int n, m;

vector<int> type_machine[1005];
vector<pair<int, long long> > sum[1001][1001];

long long limit = 1000000000LL;

bool can(long long temp, int need){
	
	vector<pair<int, long long> >::iterator it;
	
	long long total = 0, lenMachine;
	int l = int(min(limit, temp));
	
	for(int i = 1; i <= 1000; i++){
		
		if(type_machine[i].size() == 0)continue;
		
		// we use upper bound to chose the correct sum range given some time "temp"
		it = upper_bound(all(sum[i][temp%i]), make_pair(l, limit)); 
		if(it == sum[i][temp%i].begin())continue;
		
		it--;
		lenMachine = it - sum[i][temp%i].begin() + 1;
		
		total += (temp/i) * lenMachine + (it->second);
	}
	return total >= need;
}



int main(){

	
	cin >> n >> m;
	
	for(int i = 0; i < n; i++)	
		scanf("%d", &t[i]);
		
	
	sort(t, t + n);
	//after the greedy step of sorting to get as many working machines as we can
	//we need to evaluate for certain x copies: 
	// x/t[0] + (x - t[0])/t[1] + (x - 2*t[0])/t[2] + .....
	
	
	for(long long i = 0; i < n; i++)
		type_machine[t[i]].pb(i * t[0]);
	
	long long aux, add, cur;
	
	for(int i = 1; i <= 1000; i++){

		if(type_machine[i].size() == 0)continue;
		for(int j = 0; j < i; j++){ //possible reminder for some number of copies when you are using machine i
		
			cur = 0;
			for(int k = 0; k < type_machine[i].size(); k++){
				
				aux = j - type_machine[i][k];
				
				if(aux >= 0)add = aux/i;
				else{
					
					if(aux%i == 0)add = aux/i;
					else add = aux/i - 1;
				}
				
				cur += add;
				sum[i][j].pb(make_pair(type_machine[i][k], cur));
			}
		}
	}

	int need;
	for(int i = 0; i < m; i++){
		
		scanf("%d", &need);
		long long lo = 0, hi = 1000000000000LL, me;
		
		while(lo < hi){
			
			me = lo + (hi - lo)/2;
			if(can(me, need))hi = me;
			else lo = me + 1;
		}
		
		
		printf("%I64d\n", lo);
	}

}
