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 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N,Q;
    cin >> N >> Q;

    vector<i64> A(N);
    rep(i,0,N) cin >> A[i];

    vector<i64> s(N),t(N);
    s[0]=A[0];
    t[0]=A[0];
    rep(i,1,N){
        s[i]=s[i-1]+A[i];
        if(i%2==0) t[i]=t[i-1]+A[i];
        else t[i]=t[i-1];
    }

    function<i64(i64,i64)> f=[&](i64 n, i64 turn){
        if(n<0) return i64(0);
        if(turn==1) return f(n-1,(turn+1)%2);
        return n%2==0?t[n]:s[n]-t[n];
    };

    rep(_,0,Q){
        i64 X;
        cin >> X;

        {
            i64 l=0,r=N/2-1;
            i64 d=max(abs(X-A[l]),abs(X-A[r]));
            if(min(abs(X-A[r+1]),abs(X-A[N-1]))>=d){
                cout << s[N-1]-s[r] << endl;
                continue;
            }
        }

        auto ok=[&](i64 w){
            i64 r=N-1-w;
            if(r<=0) return false;
            if(X<=A[r]) {
                i64 d=A[r]-X;
                i64 l=lower_bound(begin(A),end(A),X-d)-begin(A);
                assert(l<=r);
                i64 v=r-l+1;
                return v==w; // ??
            } else{
                if(A[r+1]<=X or X-A[r]>A[r+1]-X) return false;
                i64 l=r-w+1;
                return l==r or X-A[l+1]<=A[r+1]-X;
            }
        };

        i64 lb=1,ub=N+1;
        while(ub-lb>1){
            i64 mid=(lb+ub)/2;
            if(ok(mid)) lb=mid;
            else ub=mid;
        }

        i64 w=lb;
        i64 r=N-1-w,l;
        if(X<=A[r]) {
            i64 d=A[r]-X;
            l=lower_bound(begin(A),end(A),X-d)-begin(A);
        } else{
            l=r-w+1;
        }
        cout << (s[N-1]-s[r])+f(l-1,0) << endl;
    }
}

int main(){
    //std::cin.tie(0);
    //std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}