implicit none
integer:: n,i,j,alice,bob,gap
integer:: a(n)

read(*,*) n,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
if(mod(n,2)==0)then
do i=1,n/2
alice=alice+a(i)
bob=bob+a(i+n/2)
end do
else
do i=1,(n+1)/2
alice=alice+a(i)
end do
do i=(n+3)/2,n
bob=bob+a(i)
end do

gap=alice-bob
write(*,*) gap
end
