main :: IO ()
main = do
    [n, a] <- (map read . words) <$> getLine
    ts <- (map read . words) <$> getLine
    print $ solve (n, a) ts

-- |
--
-- >>> solve (2, 4) [0, 3]
-- 7
--
-- >>> solve (2, 4) [0, 5]
-- 8
--
-- >>> solve (9, 10) [0,3,5,7,100,110,200,300,311]
-- 67
--
-- >>> solve (4, 1000000000) [0,1000,1000000,1000000000]
-- 2000000000
solve :: (Int, Int) -> [Int] -> Int
solve (n, a) ts = n * a - snd (foldl f (-a, 0) ts)
  where f (x, acc) y = (y, acc + max 0 (x + a - y))
