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
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <list>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <math.h>
#define FOR(x,y,z) for(int x = (y); x < (z); x++)
#define FORD(x,y,z) for(int x = (y); x >= z; x--)
#define REP(r,n) for(int r = 0; r < (n); r++)
#define MP make_pair
#define ST first
#define ND second
#define PB push_back
#define MAXUS 202000
#define PI 3.1415926
#define epsilon 0.000001
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<int, int> PR;

#define SIZE(c) ((int)((c).size()))
#define FOREACH(i,x) for (__typeof((x).begin()) i=(x).begin(); i!=(x).end(); i++)
#define ALL(u) (u).begin(),(u).end()

using namespace std;

bool comp(const PR &a, const PR &b) {
  return a.first < b.first || (a.first == b.first && a.second < b.second);
}



int main() {
    int n, m; // n - number of clients, m - number of bakeries
    cin >> n >> m;
    int arrive[n];
    LL presum_t_diff[n+1];
    vector<int> time_differences(n);
    vector<int> baking(m);
    int lastTime = 0;
    REP(i,n) {
        cin >> arrive[i];
        time_differences[i] = arrive[i] - lastTime;
        lastTime = arrive[i];
    }
    REP(i,m) {cin >> baking[i];}
    sort(time_differences.begin(), time_differences.end());
    presum_t_diff[0] = time_differences[0];
    FOR(i,1,n) {
        presum_t_diff[i] = presum_t_diff[i-1] + time_differences[i];
    }
    REP(i,m) {
        LL bake_time = (LL) baking[i];
        auto t = upper_bound(time_differences.begin(), time_differences.end(), bake_time);
        int index = t - time_differences.begin();
        LL result = 0;
        if (index > 0) {
            result += index * bake_time - presum_t_diff[index-1];
        }
        cout << result << endl;
    }

    return 0;
}