program main
implicit none
integer:: n,i,j,b,alice,bob,gap
integer,allocatable:: a(:)
 
read(*,*) n
allocate(a(n))
read(*,*) a
 
do j=1,n
do i=1,n-1
if(a(i)<a(i+1))then
b=a(i+1)
a(i+1)=a(i)
a(i)=b
endif
end do
end do
 
alice=0
bob=0
 
do i=1,n
if(mod(i,2)==0)then
bob=bob+a(i)
else
alice=alice+a(i)
endif
 
gap=alice-bob
write(*,*) gap
 
end program main