{-# LANGUAGE BangPatterns #-}
import Data.List
import Data.Maybe
import Control.Monad
import Data.Function (fix)
import Data.Array (Array, array, (!))
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
 
getInts :: IO [Int]
getInts = (map parseInt . BS8.words) <$> BS.getLine 
    where parseInt = fst . fromJust . BS8.readInt

solve :: Int -> [Int] -> Int
solve t = fst . foldl (\(a,b) x -> (a + min t (x+t-b), x+t)) (0,0)

main :: IO ()
main = do
    [_, t] <- getInts
    arr <- getInts
    print $ solve t arr