main :: IO ()
main = do
  [n, x] <- readInts
  ns <- readInts
  print . sum $ solve ns x


readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: [Int] -> Int -> [Int]
solve ns x = go ns
  where
    go :: [Int] -> [Int]
    go (y:z:zs) = if val < 0
                  then 0 : go (z:zs)
                  else val : go (z-val:zs)
      where
        val = z + y - x
    go _ = []
