import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Heap as H
main=print.solve.unfoldr(B.readInt.B.dropWhile isSpace)=<<B.getContents
solve(n:m:as)=foldr(\a s->s-truncate a)0$H.toUnsortedList$f m$H.fromList$map(fromIntegral.negate)as
f m q=foldr(\_ q->H.insert(H.minimum q*0.5)$H.deleteMin q)q[1..m]