module Main where
import qualified Data.Set as S
import qualified Data.ByteString.Char8 as B
import Data.List(sortOn, foldl')

readIntPair :: B.ByteString -> (Int,Int)
readIntPair s = p
    where
    Just p = do
        (n1, s') <- B.readInt s
        (n2, _ ) <- B.readInt (B.tail s')
        return (n1,n2)

main :: IO ()
main = do
    n <- fmap read getLine :: IO Int
    asbs <- fmap (map readIntPair . B.lines) B.getContents
    let l  = reverse $ sortOn (uncurry (+)) asbs
        ps = cycle [1,-1]
        ans = foldl' (\acc ((a,b),p) -> if p == 1 then acc + a else acc - b) 0 $
                (zip l ps)
    print ans                
