import           Control.Monad
import           Data.Array
import qualified Data.ByteString.Char8 as BS
import           Data.List
import           Data.Maybe
import           Data.Ord

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main = do
  (_:m:_) <- map (\x -> read x :: Int) . words <$> getLine
  prices <- readInts
  print $ solve m prices

solve :: Int -> [Int] -> Int
solve m prices
  | m == 0 = foldl' (+) 0 prices
  | otherwise = solve (m - 1) (head sorted `div` 2 : tail sorted)
  where
    sorted = sortOn Data.Ord.Down prices
