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 Fortran (gfortran v4.8.4) (judge verdict: Time Limit Exceeded)

program nearest_card_game
  implicit none
  integer(8)              :: n, q, x
  integer(8), allocatable :: a(:)
  integer(8)              :: i
  read(*,*) n, q
  allocate(a(n))
  read(*,*) a(1:n)
  do i = 1, q
     read(*,*) x
     write(*,'(i0)') total(a,x)
  end do
  deallocate(a)
  stop
contains
  function total(a,x) result(m)
    implicit none
    integer(8), intent(in) :: a(:), x
    integer(8)             :: m, n, i, ih, ib
    integer(8)             :: h(size(a),2), b(size(a),2)
    n = size(a)
    h(:,1) = a(n:1:-1)
    b(:,1) = abs(h(:,1) - x)
    do i = 1, n
       b(i,2) = i
    end do
    call merge_sort(n,b)
    do i = 1, n
       h(b(i,2),2) = i
    end do
    m = 0
    i = 1
    ih = 0
    ib = 0
    do
       ih = ih + 1
       do while (h(ih,1) .lt. 0 .and. ih .le. n)
          ih = ih + 1
       end do
       if (ih .gt. n) exit
       m = m + h(ih,1)
       b(h(ih,2),1) = -1
       i = i + 1
       if (i .gt. n) exit
       
       ib = ib + 1
       do while (b(ib,1) .lt. 0 .and. ib .le. n)
          ib = ib + 1
       end do
       if (ib .gt. n) exit
       h(b(ib,2),1) = -1
       i = i + 1
       if (i .gt. n) exit
    end do
    return
  end function total

  subroutine merge_sort(n,c)
    implicit none
    integer(8), intent(in)    :: n
    integer(8), intent(inout) :: c(n,2)
    integer(8)                :: number, length, i, ubound
    number = n
    length = 1
    do while (number .gt. 1)
       do i = 1, number/2
          ubound = min(2*i*length,n)
          call merge(c(2*(i-1)*length+1:(2*i-1)*length,:),c((2*i-1)*length+1:ubound,:))
       end do
       length = 2*length
       number = (number+1)/2
    end do
    return
  end subroutine merge_sort
  
  subroutine merge(c1,c2)
    implicit none
    integer(8), intent(inout) :: c1(:,:), c2(:,:)
    integer(8)                :: c(size(c1(:,1))+size(c2(:,1)),size(c1(1,:)))
    integer(8)                :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(c1(:,1))
    n2 = size(c2(:,1))
    do while (i1 .le. n1 .and. i2 .le. n2)
       if (c1(i1,1) .lt. c2(i2,1)) then
          c(i1+i2-1,:) = c1(i1,:)
          i1 = i1+1
       else if (c1(i1,1) .gt. c2(i2,1)) then
          c(i1+i2-1,:) = c2(i2,:)
          i2 = i2+1
       else if (c1(i1,2) .gt. c2(i2,2)) then
          c(i1+i2-1,:) = c1(i1,:)
          i1 = i1+1
       else
          c(i1+i2-1,:) = c2(i2,:)
          i2 = i2+1
       end if
    end do
    if (i1 .le. n1) then
       c(i1+i2-1:n1+n2,:) = c1(i1:n1,:)
    else if (i2 .le. n2) then
       c(i1+i2-1:n1+n2,:) = c2(i2:n2,:)
    end if
    c1 = c(1:n1,:)
    c2 = c(n1+1:n1+n2,:)
    return
  end subroutine merge
end program nearest_card_game