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

main = do
  n <- (read::String -> Int) <$> getLine
  arr1 <- array (1, n + 1) . zip [1..(n + 1)] . map (read::String -> Int) . words <$> getLine
  arr2 <- array (1, n) . zip [1..n] . 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] [1..n]
