import Control.Applicative

f :: [Int] -> [Int]
f [x] = []
f (x:y:zs) = (y - x) : f (y:zs)

g :: Int -> [Int] -> Int
g _ [] = 0
g n (x:xs) = if x <= n then (n - x) + g n xs
                     else g n xs

main = do
  t <- (\[x,y] -> y) . map read . words <$> getLine :: IO Int
  times <- map read . words <$> getLine :: IO [Int]
  putStrLn $ show $ (length times) * t - (g t . f) times