import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl (wrds toInt) <*> getl (wrds toInt) >>= print

solve :: [Int] -> [Int] -> Int
solve [n, x] as = h . g . transpose . f n $ [[(0,i)| i <- as]]
  where
    f m ys
      | m == 1 = ys
      | otherwise = let zs = (tail.head) ys ++ [(head.head) ys] in f (m-1)  (map (\(i,j) -> (i+1,j)) zs : ys)
    g ys = map (minimumBy (\(i,j) (k,l) -> (i*x+j) `compare` (k*x+l))) ys
    h ys = (sum . map snd) ys + (maximum . map fst) ys * x
    
toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine
