PROGRAM ATCODER

implicit none
integer(8) :: n,i,j,s,t,u,dif
integer(8),allocatable :: a(:), b(:), c(:)

read(*,*) n
allocate(a(n)) ; allocate(b(n)) ; allocate(c(n))

do i = 1, n
    read(*,*) a(i),b(i)
    c(i) = b(i) + a(i)
end do

do i = 1, n
    do j = i+1, n
        if (c(j) > c(i))then
            s = c(i) ; t = a(i) ; u = b(i)
            c(i) = c(j) ; a(i) = a(j) ; b(i) = b(j)
            c(j) = s ; a(j) = t ; b(j) = u
        end if
    end do
end do

dif = 0
if (mod(n,2) == 0)then
    do i = 1, n-1, 2
        dif = dif + a(i) - b(i+1)
    end do
else
    do i = 1, n-2, 2
        dif = dif + a(i) - b(i+1)
    end do
        dif = dif +  a(n)
end if

write(*,'(i0)') dif

END PROGRAM ATCODER
