Problem:
Score : 500 points

Problem Statement

There are N cards. The i-th card has an integer A_i written on it.
For any two cards, the integers on those cards are different.

Using these cards, Takahashi and Aoki will play the following game:

Aoki chooses an integer x.

Starting from Takahashi, the two players alternately take a card. The card should be chosen in the following manner:

Takahashi should take the card with the largest integer among the remaining card.

Aoki should take the card with the integer closest to x among the remaining card. If there are multiple such cards, he should take the card with the smallest integer among those cards.

The game ends when there is no card remaining.

You are given Q candidates for the value of x: X_1, X_2, ..., X_Q.
For each i (1 \leq i \leq Q), find the sum of the integers written on the cards that Takahashi will take if Aoki chooses x = X_i.

Constraints

2 \leq N \leq 100 000

1 \leq Q \leq 100 000

1 \leq A_1 < A_2 < ... < A_N \leq 10^9

1 \leq X_i \leq 10^9 (1 \leq i \leq Q)

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N Q
A_1 A_2 ... A_N
X_1
X_2
:
X_Q

Output

Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x = X_i.

Sample Input 1

5 5
3 5 7 11 13
1
4
9
10
13

Sample Output 1

31
31
27
23
23

For example, when x = X_3(= 9), the game proceeds as follows:

Takahashi takes the card with 13.

Aoki takes the card with 7.

Takahashi takes the card with 11.

Aoki takes the card with 5.

Takahashi takes the card with 3.

Thus, 13 + 11 + 3 = 27 should be printed on the third line.

Sample Input 2

4 3
10 20 30 40
2
34
34

Sample Output 2

70
60
60

Solution in C++14 (Clang 3.8.0) (judge verdict: Wrong Answer)

#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000, MAX_Q = 100000;
int N, Q;
ll A[MAX_N];
ll X[MAX_Q];
ll sum_odd[MAX_N];
ll sum_even[MAX_N];
ll sum[MAX_N];

int main() {
  std::ios::sync_with_stdio(false);std::cin.tie(0);
  cin >> N >> Q;
  rep(i, N) cin >> A[i];
  rep(i, Q) cin >> X[i];

  sum_even[0] = A[0];
  sum_odd[1] = A[1];
  for (int i = 2; i < N; i += 2) {
      sum_even[i] = A[i] + sum_even[i-2];
  }
  for (int i = 3; i < N; i += 2) {
      sum_odd[i] = A[i] + sum_odd[i-2];
  }
  sum[0] = A[0];
  for (int i = 1; i < N; ++i) sum[i] = A[i] + sum[i-1];

  for (int q = 0; q < Q; ++q) {
      int x = X[q];

      int lb = 0, ub = 1e9+10, mid;
      while (ub-lb > 1) {
          mid = (lb+ub)/2;
          int _idx1 = lower_bound(A, A+N, max(x-mid, 0)) - A;
          int _idx2 = upper_bound(A, A+N, x+mid)- A;
          int _aoki = _idx2-_idx1, _takahashi = N-_idx2;
          if (_aoki >= _takahashi) ub = mid;
          else lb = mid;
      }

      int idx1 = lower_bound(A, A+N, max(x-ub, 0)) - A;
      int idx2 = upper_bound(A, A+N, x+ub) - A;
      int aoki = idx2-idx1, takahashi = N-idx2;

      ll ans = 0;
      if (aoki == takahashi) {
          ans = sum[N-1]-sum[idx2-1];
          if (0 <= idx1-1 && (idx1-1)%2 == 0) ans += sum_even[idx1-1];
          if (0 <= idx1-1 && (idx1-1)%2 == 1) ans += sum_odd[idx1-1];
      } else if (aoki == takahashi+1) {
          int addIdx = idx2-1;
          if (abs(A[idx1]-x) > abs(A[idx2-1]-x)) addIdx = idx1;
          ans = sum[N-1]-sum[idx2-1];
          ans += A[addIdx];
          if (0 <= idx1-2 && (idx1-2)%2 == 0) ans += sum_even[idx1-2];
          if (0 <= idx1-2 && (idx1-2)%2 == 1) ans += sum_odd[idx1-2];
      } else if (aoki == takahashi+2) {
          ans = sum[N-1]-sum[idx2-2];
          if (0 <= idx1-1 && (idx1-1)%2 == 0) ans += sum_even[idx1-1];
          if (0 <= idx1-1 && (idx1-1)%2 == 1) ans += sum_odd[idx1-1];
      }


      cout << ans << endl;
  }

  return 0;
}