import qualified Data.IntMap as M

main = do
  li <- getLine
  let [n,m] = map read $ words li
  li <- getLine
  let as = map read $ words li
  let ans = compute n m as
  print ans

{-
IntMapのheap的能力
deleteFindMax :: IntMap a -> ((Key, a), IntMap a)
insertWith :: (a -> a -> a) -> Key -> a -> IntMap a -> IntMap a
で券がなくなるまでどんどん半額にしていく。
-}

compute :: Int -> Int -> [Int] -> Int
compute n m as = sum $ map (uncurry (*)) $ loop m am
  where
    am = M.fromListWith (+) [ (a,1) | a <- as ]
    loop m am
      | m > c = loop (m-c) $ M.insertWith (+) (div x 2) c am1
      | True  = (div x 2, m) : (x, c - m) : M.assocs am1
      where
        ((x,c),am1) = M.deleteFindMax am