module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust, fromMaybe)
import qualified Data.Map.Strict as M


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

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

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

type PQ = M.Map Int Int
fromListPQ :: [Int] -> PQ
fromListPQ nums = foldr insertPQ M.empty nums

toListPQ :: PQ -> [(Int, Int)]
toListPQ pq =  M.toList pq

insertPQ :: Int -> PQ -> PQ
insertPQ n pq = case M.lookup n pq of
    Nothing -> M.insert n 1 pq
    Just a -> M.insert n (a + 1) pq

takePQ :: Int -> PQ -> PQ
takePQ n pq = let
    updator old = if old < 2 then Nothing else Just $ old - 1
    in
        M.update updator n pq

getLargest :: PQ -> Int
getLargest pq = fst  $ M.findMax pq

modifyLargest :: (Int -> Int) -> PQ -> PQ
modifyLargest f pq = let
    largest = getLargest pq
    deleted = takePQ largest pq
    newVal = f largest
    in 
        insertPQ newVal deleted


solve :: [Int] -> Int -> Int
solve as waribiki = let
    inner :: PQ -> Int -> Int
    inner pq 0 = sum $ (\(num, count) ->  num * count) <$>  toListPQ pq
    inner pq waribiki = inner (modifyLargest (`div`2) pq) $ waribiki - 1
    in
        inner (fromListPQ as) waribiki

main = do
    (n, m) <- readTuple2
    as <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    print $ solve as m
