import sys

input = sys.stdin.readline

from collections import *

from bisect import *



def judge(x):

    tak = N-x

    aoki = x-bisect_left(A, 2*X-A[x])+1

    

    return tak<=aoki



def binary_search():

    l, r = mark, N-1

    

    while l<=r:

        m = (l+r)//2

        

        if judge(m):

            r = m-1

        else:

            l = m+1

    

    return l



N, Q = list(map(int, input().split()))

A = list(map(int, input().split()))

acc = [0]

acc_e = [0]



for i in range(N):

    acc.append(acc[-1]+A[i])

    acc_e.append(acc_e[-1]+(A[i] if i%2==0 else 0))



for _ in range(Q):

    X = int(eval(input()))

    mark = bisect_left(A, X)

    border = binary_search()

    ans = acc[-1]-acc[border]

    c = N-border

    

    if 2*c>=N:

        print(ans)

        continue

    

    if (N-2*c-1)%2==0:

        ans += acc_e[N-2*c]

    else:

        ans += acc[N-2*c]-acc_e[N-2*c]

    

    print(ans)
import sys

input = sys.stdin.readline

from collections import *

from bisect import *



def judge(x):

    aoki = N-x-bisect_left(A, 2*X-A[N-x])+1

    return x<=aoki

    

def binary_search():

    l, r = 1, N-bisect_left(A, X)

    

    while l<=r:

        m = (l+r)//2

        

        if judge(m):

            l = m+1

        else:

            r = m-1

    

    return r



N, Q = list(map(int, input().split()))

A = list(map(int, input().split()))

A.sort()

acc = [0]

acco = [0]



for i in range(N):

    acc.append(acc[-1]+A[i])

    

    if i%2==1:

        acco.append(acco[-1]+A[i])

    else:

        acco.append(acco[-1])



for _ in range(Q):

    X = int(eval(input()))

    x = binary_search()

    ans = acc[N]-acc[N-x]

    

    if N-2*x>0:

        if (N-2*x)%2==0:

            ans += acco[N-2*x]

        else:

            ans += acc[N-2*x]-acco[N-2*x]

        

    print(ans)
import sys

input = sys.stdin.readline
from collections import *
from bisect import *


def judge(x):
    tak = N - x
    aoki = x - bisect_left(A, 2 * X - A[x]) + 1
    return tak <= aoki


def binary_search():
    l, r = mark, N - 1
    while l <= r:
        m = (l + r) // 2
        if judge(m):
            r = m - 1
        else:
            l = m + 1
    return l


N, Q = list(map(int, input().split()))
A = list(map(int, input().split()))
acc = [0]
acc_e = [0]
for i in range(N):
    acc.append(acc[-1] + A[i])
    acc_e.append(acc_e[-1] + (A[i] if i % 2 == 0 else 0))
for _ in range(Q):
    X = int(eval(input()))
    mark = bisect_left(A, X)
    border = binary_search()
    ans = acc[-1] - acc[border]
    c = N - border
    if 2 * c >= N:
        print(ans)
        continue
    if (N - 2 * c - 1) % 2 == 0:
        ans += acc_e[N - 2 * c]
    else:
        ans += acc[N - 2 * c] - acc_e[N - 2 * c]
    print(ans)

import sys

input = sys.stdin.readline
from collections import *
from bisect import *


def judge(x):
    aoki = N - x - bisect_left(A, 2 * X - A[N - x]) + 1
    return x <= aoki


def binary_search():
    l, r = 1, N - bisect_left(A, X)
    while l <= r:
        m = (l + r) // 2
        if judge(m):
            l = m + 1
        else:
            r = m - 1
    return r


N, Q = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
acc = [0]
acco = [0]
for i in range(N):
    acc.append(acc[-1] + A[i])
    if i % 2 == 1:
        acco.append(acco[-1] + A[i])
    else:
        acco.append(acco[-1])
for _ in range(Q):
    X = int(eval(input()))
    x = binary_search()
    ans = acc[N] - acc[N - x]
    if N - 2 * x > 0:
        if (N - 2 * x) % 2 == 0:
            ans += acco[N - 2 * x]
        else:
            ans += acc[N - 2 * x] - acco[N - 2 * x]
    print(ans)

-    tak = N - x -    aoki = x - bisect_left(A, 2 * X - A[x]) + 1 -    return tak <= aoki +    aoki = N - x - bisect_left(A, 2 * X - A[N - x]) + 1 +    return x <= aoki -    l, r = mark, N - 1 +    l, r = 1, N - bisect_left(A, X) +            l = m + 1 +        else: -        else: -            l = m + 1 -    return l +    return r +A.sort() -acc_e = [0] +acco = [0] -    acc_e.append(acc_e[-1] + (A[i] if i % 2 == 0 else 0)) +    if i % 2 == 1: +        acco.append(acco[-1] + A[i]) +    else: +        acco.append(acco[-1]) -    mark = bisect_left(A, X) -    border = binary_search() -    ans = acc[-1] - acc[border] -    c = N - border -    if 2 * c >= N: -        print(ans) -        continue -    if (N - 2 * c - 1) % 2 == 0: -        ans += acc_e[N - 2 * c] -    else: -        ans += acc[N - 2 * c] - acc_e[N - 2 * c] +    x = binary_search() +    ans = acc[N] - acc[N - x] +    if N - 2 * x > 0: +        if (N - 2 * x) % 2 == 0: +            ans += acco[N - 2 * x] +        else: +            ans += acc[N - 2 * x] - acco[N - 2 * x]