program test
  implicit none
  integer :: n, a(100), k, l, i
  a=0
  k=0
  l=0
  read(*,*) n
  read(*,*) a(1:n)
  call quick_sort(a(1:n))
  do i=1,n
  	if(mod(i,2)==1)then
    	k=k+a(n-i+1)
    else
    	l=l+a(n-i+1)
    end if
  end do
  write(*,*)k-l
  stop
contains
  recursive subroutine quick_sort(a)
    implicit none
    integer, intent(inout) :: a(:)
    integer :: p, c
    integer :: n, l, r
    n = size(a)
    l = 1
    r = n
    p = a((l+r)/2)+a(l)+a(r)-max(a((l+r)/2),a(l),a(r))-min(a((l+r)/2),a(l),a(r))
    do
      do while (a(l).lt.p)
        l = l+1
      end do
      do while (a(r).gt.p)
        r = r-1
      end do
      if (l.ge.r) exit
      c = a(l)
      a(l) = a(r)
      a(r) = c
      l = l+1
      r = r-1
    end do
    if (l.gt.2) call quick_sort(a(1:l-1))
    if (n.gt.r+1) call quick_sort(a(r+1:n))
  end subroutine quick_sort
end program test