import Data.List

main = do
  [_,x] <- map read . words <$> getLine
  as <- map read . words <$> getLine
  print (candies x as)

candies x = fst . foldl' (eat x) (0,0)

eat x (acc,rest) a = let n = max 0 (rest+a-x) in (acc+n, a-n)