import Data.List

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

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

ksp k l = [y | y <- sp l, length y == k]

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
  let gar0 = 0:gar
  putStrLn $ show $ (n*x +) $ minimum $ map (sumcost x) $ sp gar0