main = do 
  n <- getLine
  xs <- map read . words <$> getLine
  ys <- map read . words <$> getLine
  putStrLn . show $ solve xs ys

solve :: [Int] -> [Int] -> Int
solve xs ys = inSolve (sum ys) xs ys

inSolve xysum [] [] = xysum
inSolve xysum (x:xs) (y:ys) = max (x + xysum) $ inSolve (xysum - y + x) xs ys
  
