import Control.Applicative ((<$>))

solve t (x:xs)
  | xs == [] = [t]
  | t > (head xs) - x = (head xs) - x : solve t xs
  | otherwise = t : solve t xs

main = do
  [n, t] <- fmap read <$> words <$> getLine :: IO [Int]
  ts <- fmap read <$> words <$> getLine :: IO [Int]
  putStrLn (show (sum (solve t ts)))
