{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Char8 as BS
import Data.Char
import Debug.Trace
import Data.List (unfoldr)
import Control.Monad
import qualified Data.Vector.Unboxed as UV

main = do
    n <- UV.head . UV.unfoldr BS.readInt <$> BS.getLine
    a <- UV.unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    b <- UV.unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    -- let l = UV.length $ UV.filter not $ UV.zipWith (==) p (UV.fromList [1..n])
    -- putStrLn $ if l <= 2 then "YES" else "NO"
    print $ sub3 0 a b

sub3 :: Int -> UV.Vector Int -> UV.Vector Int -> Int
sub3 m0 a b
    | b == UV.empty = 0
    | otherwise     = minX + sub3 m (UV.tail a) (UV.tail b)
    where t1 = UV.head a - m0
          t2 = UV.last $ UV.take 2 a
          r = UV.head b
          minX = min (t1 + t2) r
          m | r <= t1        = 0
             | r <= (t1 + t2) = r - t1
             | otherwise      = t2
