kr :: [Integer] -> [Integer] -> Integer
kr [y] [x] = min y x
kr (y:ys) (x:x':xs) = min y x + kr ys ((x' + x-min y x):xs)

main = do
    _ <- getLine
    a <- map read . words <$> getLine :: IO [Integer]
    b <- map read . words <$> getLine :: IO [Integer]
    print $ kr a (b++[0])
