import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as VU
import Data.Char

solve :: VU.Vector Int -> Int -> Int
solve vec t = (fst $ VU.foldl' step (0, 0) vec) + t
    where
        step (a, b) v
            | b + t < v = (a + t, b)
            | otherwise = (a + (v - a) , b)

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