import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.Array
import Data.Foldable
import Data.Function

main :: IO ()
main = do
  [n, x] <- map read . words <$> getLine
  a <- listArray (1, n) . (map (fst . fromJust . BS.readInt) . BS.words) <$> BS.getLine
  let
    solve [] (_, i) = (0, i)
    solve (y:ys) (s, i) =
      let
        (next, j) = if s + x * (i+1) < y then (s, i+1) else (y, i)
      in (\x1 (x2, y2) -> (x1 + x2, y2)) next $ solve ys (next, j)
    ans = flip map [1..n] $ \i -> let
        po = flip map [1..n] $ \j -> (a ! j + x * (if i <= j then j - i else n + j - i), j, if i <= j then j - i else n + j - i)
        (f, s, t) = minimumBy (compare `on` (\(fs, _, _) -> fs)) po
      in (s, t)
    ma = maximum $ map snd ans
  print $ foldl (\m j -> m + a ! j) 0 (map fst ans) + x * ma
