program main
  implicit none
  
  integer :: n,i,j,t,a(100) = 0,al=0,bo=0,endal,endbo
  
  read(*,*)n
  read(*,*)(a(i),i=1, n)
  
  if (n == 1) then
    write(*,*)a(i)
    stop
  end if
  
  do i=1,N-1
     do j=i+1,N
        if(a(i) .gt. a(j))then
           t=a(i)
           a(i)=a(j)
           a(j)=t
        end if
     end do
  end do
  if (mod(n,2)==0) then
    endal = 2
    endbo = 1
  else
    endal = 1
    endbo = 2
  end if
  do i = n, endal, -2
    al = al + a(i)
  end do
  
  do i = n-1, endbo, -2
    bo = bo + a(i)
  end do
  write(*,*)al-bo
end program main