module Main where

import           Control.Monad
import           Data.List
import           Data.Ord
import           Data.List.Split
import           Data.Array.IO
import qualified Data.Vector            as V
import           Data.Maybe
import           Text.Printf

main :: IO ()
main = do
  _ <- getLine
  vs <- map read . words <$> getLine
  cs <- map read . words <$> getLine
  print $ (max 0 . f . sortBy (flip compare) . zipWith (-) vs) cs
  where
    f as = sum $ 0:filter (>= 0) as
