import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Char
import Control.Monad

solve :: VU.Vector Int -> Int -> Int -> IO Int
solve vec n x = do
        vec' <- VU.unsafeThaw vec
        res <- forM [0..n-2] $ \i -> do
                adjust vec' (i,i+1) x
        return $ sum res
    where
        adjust :: VUM.IOVector Int -> (Int, Int) -> Int -> IO Int
        adjust vec (i,j) x = do
            iv <- VUM.read vec i
            jv <- VUM.read vec j
            let diff = max (iv+jv-x) 0
            unless (diff == 0) $ do
                if (jv >= diff)
                    then do
                        VUM.write vec j (jv-diff)
                    else do
                        VUM.write vec j 0
                        VUM.write vec i (iv + (jv-diff))
            return diff

main = do
    [n, x] <- map read . words <$> getLine :: IO [Int]
    as <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
    solve as n x >>= print