import Control.Applicative
import Data.List
strToInteger s = (read :: String -> Integer) s

main :: IO ()
main = do
    -- スペース区切り整数の入力
    [n, x] <- map strToInteger . words <$> getLine
    -- スペース区切り整数の入力
    as <- map strToInteger . words <$> getLine
    let as' = if x < head as then x:(drop 1 as) else as
    -- 出力
    putStrLn . show $ ((sum as) - (sum $ operate as' x))

operate :: [Integer] -> Integer -> [Integer]
operate (a1:[]) x = [a1]
operate (a1:a2:bs) x
    | a1 + a2 <= x = (:) a1 $ operate (a2:bs) x
    | otherwise    = (:) a1 $ operate (a2':bs) x where a2' = x - a1
