1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (int i=0, ___=(n); i<___; ++i)
#define FOR(i, a, b) for (int i=(a), ___=(b); i<=___; ++i)
#define FORD(i, a, b) for (int i=(a), ___=(b); i>=___; --i)

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, ll> PIL;

int read() { int n; cin >> n; return n; }
ll readl() { ll n; cin >> n; return n; }

void brut(const vector<ll> &t, const vector<int> &d, vector<ll> &res) {
	int n = t.size();
	int m = d.size();
	REP(i, m) {
		ll cur = 0;
		ll r = 0;
		REP(j, n) {
			if (cur + d[i] <= t[j]) {
				cur = t[j];
				continue;
			}
			r += cur + d[i] - t[j];
			cur += d[i];
		}
		res[i] = r;
	}
}

void solve(const vector<ll> &t, const vector<int> &d, vector<ll> &res) {
	brut(t, d, res);
}





int main() {
	int n = read();
	int m = read();

	vector<ll> t(n);
	vector<int> d(m);

	REP(i, n) t[i] = readl();
	REP(i, m) d[i] = read();

//	vector<ll> resBrut(m);
	vector<ll> res(m);

//	brut(t, d, resBrut);
	solve(t, d, res);

//	REP(i, m) cout << resBrut[i] << "\n";
	REP(i, m) cout << res[i] << "\n";

	return 0;
}