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# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

static class Ex{
	public static int LowerBound<T>  (this IList<T> a, T v) where T:IComparable<T> {
		if(a[0].CompareTo(v) >= 0) return 0;
		int l = 0, r = a.Count;
		while(r - l > 1){
			int c = (r + l) / 2;
			if(a[c].CompareTo(v) < 0) l = c;
			else r = c;
		}
		return r;
	}
}

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long[][] S = new long[2][];
		for(int i=0;i<2;i++) S[i] = new long[N + 1];
		for(int i=0;i<N;i++){
			for(int j=0;j<2;j++){
				S[j][i + 1] += S[j][i] + (i % 2 == j ? A[i] : 0);
			}
		}
		
		long[] ans = new long[Q];
			
		
		for(int i=0;i<Q;i++){
			var x = X[i];
			int idx = A.LowerBound(x);
//Console.Error.WriteLine("idx:{0}",idx);			
			if(idx == N) idx--;
//Console.Error.WriteLine("tf:{0}",idx > 0 && Math.Abs(x - A[idx - 1]) <= Math.Abs(x - A[idx]));
			if(idx > 0 && Math.Abs(x - A[idx - 1]) <= Math.Abs(x - A[idx])) idx--;
//Console.Error.WriteLine("idx:{0}",idx);			
			int l = 1, r = N;
			while(r - l > 1){
				// 高橋君が右側c個取れる
				// atatataaAatttT c == 4
				int c = (r + l) / 2;
				if(possible(c, idx, x, X)){
					l = c;
				} else {
					r = c;
				}
			}
			
	//cerr << "i:" << i << " l:" << l << endl;
			
			long taka = (S[0][N] - S[0][N - l]) + (S[1][N] - S[1][N - l]);
			int rest = N - l - (l - 1);
			if(rest % 2 == 1){
				taka += S[1][rest];
			} else {
				taka += S[0][rest];
			}
			// ll aoki = (S[0][N] + S[1][N]) - taka;
			ans[i] = taka;
			
		}
		Console.WriteLine(String.Join("\n", ans));
		
	}
	

	bool possible(int c, int idx, long x, long[] a){
		// 高橋君が右側c個取れる．青木君はidxから始まる
		// atatataaAatttT c == 4
		int N = a.Length;
		if(c == 1) return true;
		if(N - c <= idx) return false;
		if(2 * c - 2 >= N) return false;
		
		// 高橋君が右側c-1個取り終わっていて，
		// 青木君がc-1個目としてA[N-c]を必ず取らなければいけない場合はfalse，
		// それ以外はtrue
		
		// 右にまだ余裕がある
		if(idx + (c - 2) < N - c) return true;
		
		// 右はN-c-1まで取っているとして，N-cを取るより左側をとる方が理にかなっている
		int nl = N - c - 1 - (c - 2);
		if(nl < 0) return false;
		if(Math.Abs(a[nl] - x) <= Math.Abs(a[N - c] - x)) return true;
		return false;
		
	}
	
	
	
	int N,Q;
	long[] A,X;
	public Sol(){
		var d = ria();
		N = d[0]; Q = d[1];
		A = rla();
		X = new long[Q];
		for(int i=0;i<Q;i++) X[i] = rl();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}