main :: IO ()
main = do
    [n,t] <- map read . words <$> getLine :: IO [Integer]
    ts <- map read . words <$> getLine :: IO [Integer]
    let m = sum $ map (\n -> max 0 (-(n - t))) $ f ts
    print $ n*t - m

f (n:m:ns) = m - n : f (m:ns)
f _ = []