import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

paint :: [Integer] -> Integer -> Integer -> Integer
paint [] t' s = s
paint [t] t' s = paint [] t' (s+t')
paint (t:ts) t' s = paint ts'' t' s'
  where
    (ts', ts'') = partition (<= t + t') (t:ts)
    s' = s + last ts' + t' - t

main = do
  [n, t] <- getIntList
  ts <- getIntList
  print $ paint ts t 0
