import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Ord 

main :: IO ()
main = getLine >> readContents 2 >>= print . solve

solve :: [[Int]] -> Int
solve [vs, cs] = count 0 . sortOn Down . map mf $ zip vs cs
    where
        count acc (x : xs)
            | x > 0 = count (acc + x) xs
            | otherwise = acc
        count acc _ = acc 

        mf (v, c) = v - c

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine