import Data.List

main :: IO ()
main = do
  n <- readLn :: IO Int
  vs <- map read.words <$> getLine
  cs <- map read.words <$> getLine
  let vc = zip vs cs
      ls = map (\l -> (sum (map fst l)) - (sum (map snd l))) $ subsequences vc
  print $ maximum ls
