
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad

import qualified Data.IntMap as M
import qualified Data.Sequence as S

import Data.Foldable(toList)
import Data.Maybe(fromMaybe)
import Debug.Trace

r :: IO [Int]
r  = unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine
    where toTup [a,b] = (a,b)


main :: IO ()
main = do
    [n,m] <- r :: IO [Int]
    as <- r
    let mp = S.unstableSort $ S.fromList as
    let r = sum $ solve m mp
    print r

solve :: Int -> S.Seq Int -> S.Seq Int
solve 0 xs = xs
solve m xs = let    len = S.length xs
                    lst = S.index xs (len-1)
        in solve (m-1) (ins (lst `div` 2) (S.take (len-1) xs))


ins :: Int -> S.Seq Int -> S.Seq Int 
ins n xs = let (l,r) = S.breakl (>n) xs in 
    l S.>< (n S.<| r)
