{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE FlexibleContexts #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Sequence as Seq
import Data.Sequence (Seq)
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function
import Control.Monad.Primitive
import qualified Data.Vector.Primitive.Mutable as VPM
import qualified Data.Vector.Generic.Mutable as VGM
import Data.STRef
import Data.IORef

main :: IO ()
main = do
  [n,q] <- map read . words <$> getLine :: IO [Int]
  as <- VU.unfoldrN n (BS.readInt . BS.dropWhile (==' ')) <$> BS.getLine
  let asum = VU.scanl' (+) 0 as
      aIntSum = VU.map fst $ VU.scanl' (\(!x,!y) a -> (y+a,x)) (0,0) as
  xs <- VU.unfoldrN q (BSL.readInt . BSL.dropWhile (<'!')) <$> BSL.getContents
  VU.forM_ xs $ \x ->
    print (query n as asum aIntSum x :: Int)

query n as asum aIntSum x
  = asum VU.! n - asum VU.! (n-divpt) + aIntSum VU.! (max 0 $ n-divpt*2)
  where
    -- How many entries >= x can takahashi take?
    divpt = (gone+1) `shiftR` 1
    -- How many cards are taken before all cards >= x are gone?
    gone = gone_binSearch 0 $ n+1
    gone_binSearch :: Int -> Int -> Int
    gone_binSearch !ok !ng -- at least ok cards are taken; ng cards are never.
      | ng - ok <= 1 = ok
      | as VU.! (n - (mid+1) `shiftR` 1) - x >= x - as VU.! mid
        = gone_binSearch mid ng
      | otherwise = gone_binSearch ok ng
      where
        mid = (ok + ng) `shiftR` 1
