import qualified Data.ByteString.Char8 as BS
main = do
  [_,t] <- map (read . BS.unpack) . BS.words <$> BS.getLine :: IO [Int]
  ts <- map (read . BS.unpack) . BS.words <$> BS.getLine :: IO [Int] 
  print $ solve ts t

solve :: [Int] -> Int -> Int
solve [_] t = t
solve (x:y:xs) t = min t (y-x) + solve (y:xs) t