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

main :: IO ()
main = do
  n <- readB <$> B.getLine
  as <- map readB . B.words <$> B.getLine
  bs <- map readB . B.words <$> B.getLine
  print $ snd . solve $ zip as bs

readB :: B.ByteString -> Int
readB = fst . fromJust . B.readInt

solve :: [(Int, Int)] -> (Int, Int)
solve = foldr op (0, 0)

op :: (Int, Int) -> (Int, Int) -> (Int, Int)
op (a, b) (c, d) = (x, y)
  where
    x = c + a
    y = d + max b x

