output_description: Print Q lines. The i-th line (1 \leq i \leq Q) should contain the answer for x
  = X_i.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N Q
      A_1 A_2 ... A_N
      X_1
      X_2
      :
      X_Q
attempt: import bisect
  n,q=map(int,input().split())
  a=list(map(int,input().split()))
  x=[0]*q
  ans=[0]*q
  for i in range(q):
      x[i]=int(input())
  
  aa=0
  k=a[n//2:]
  aa=sum(k)
      
  bb=0
  c=list(a)
  while len(c)>0
      bb+=c[len(c)-1]
      c.pop()
      if len(c)>0:
          c.pop():
  
  
  
  
  for i in range(q):
      b=list(a)
      xx=x[i]
      sum=0
      ll=bisect.bisect_left(b, xx)-1
      if ll<=len(b)//4:
          ans[i]=aa
      elif ll>=len(b)//2+len(b)//4:
          ans[i]=bb
      else:
          while len(b)>0:
              sum+=b[len(b)-1]
              b.pop()
              if len(b)>0:
                  ll=bisect.bisect_left(b, xx)-1
                  rr=ll+1
                  if ll>=len(b)-1:
                      b.pop()
                  elif abs(b[rr]-xx)<abs(b[ll]-xx):
                      b.pop(rr)    
                  else:
                      b.pop(ll)
          ans[i]=sum
  for i in ans:
      print(i)
problem_description: 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.
samples: [{"input": "5 5\n    3 5 7 11 13\n    1\n    4\n    9\n    10\n    13", "output": "31\n    31\n    27\n    23\n    23\n    \n\nFor example, when x = X_3(= 9), the game proceeds as follows:\n\n  * Takahashi takes the card with 13.\n  * Aoki takes the card with 7.\n  * Takahashi takes the card with 11.\n  * Aoki takes the card with 5.\n  * Takahashi takes the card with 3.\n\nThus, 13 + 11 + 3 = 27 should be printed on the third line.\n\n* * *"}, {"input": "4 3\n    10 20 30 40\n    2\n    34\n    34", "output": "70\n    60\n    60"}]