import Control.Applicative
import Control.Monad
import Data.List

main = do
  n <- (read::String -> Int) <$> getLine
  arr1 <- map (read::String -> Int) . words <$> getLine
  arr2 <- map (read::String -> Int) . words <$> getLine
  print $ sum $ foldl (
    \(x:xs) i -> if arr2 !! i > (arr1 !! i) - x 
      then (min (arr1 !! (i + 1)) ((arr2 !! i) - (arr1 !! i) + x)):(arr1 !! i):xs 
      else 0:((arr2 !! i) + x):xs
    ) [0] [0..(n - 1)]
