import Data.List

costsub :: [Int] -> Int
costsub []  = 0
costsub [b] = b
costsub (a:b:gar) = (b-a)*((length gar)+2)^2 + costsub (b:gar)

cost l = costsub (0:l)

sp :: [Int] -> [[[Int]]]
sp [x] = [[[x]]]
sp []  = [[[]]]
sp (x:xs) = [([x] ++ (head y)) : (tail y) | y <- sp xs] ++ map ([x]:) (sp xs)

sumcost :: Int -> [[Int]] -> Int
sumcost x l = x*(length l) + (sum $ map cost l)

main :: IO ()
main = do
  [n,x] <- map read . words <$> getLine :: IO [Int]
  gar   <- map read . words <$> getLine
  putStrLn $ show $ (n*x +) $ minimum $ map (sumcost x) $ sp gar