import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    getLine
    as <- getIntList
    bs <- getIntList
    print $ solve as bs

solve _ [] = 0
solve (a1:a2:as) (b:bs) = (a1 + a2 - a2') + solve (a2':as) bs
  where a2' = max 0 ((a1+a2) - b)