import qualified Data.ByteString.Char8 as B
import Data.Maybe

solve [_] [] = 0
solve (a:b:as) (x:xs)
    | a >= x = (x + b - b1) + solve (b1:as) xs
    | otherwise = (a + b - b2) + solve (b2:as) xs
    where
        b1 = max 0 (b - (a - x))
        b2 = max 0 (b - (x - a))

main = do
    n <- readLn :: IO Int
    as <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    bs <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    print $ solve as bs