import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  [[n, x], prices] <- replicateM 2 readNumStrings
  let ws = weights n x
   in print . sum . zipWith (*) ws $ prices

readNumStrings :: IO [Int]
readNumStrings = (map read . words) <$> getLine

toRevBinary :: Int -> [Int]
toRevBinary n = case n `divMod` 2 of
  (0, r) -> [r]
  (q, r) -> r : toRevBinary q

weights :: Int -> Int -> [Int]
weights n x = take n $ toRevBinary x ++ repeat 0
