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
#include <stdint.h>
#include <iostream>
#include <vector>

using namespace std;


int64_t solve(vector<int64_t> const &t, int d) {
  int n = t.size();
  int64_t ans = 0;
  int64_t end = d;
  for(int i = 0; i < n; i++) {
    int64_t n = t[i];
    end = max(end, n);
    ans += (end - n);
    end += d;
  }
  return ans;
}


int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int64_t> t(n);
  for(int i = 0; i < n; i++) {
    cin >> t[i];
  }
  for(int j = 0; j < m; j++) {
    int d;
    cin >> d;
    cout << solve(t, d) << '\n';
  }
  return 0;
}