INTEGER M,ALICE,BOB
INTEGER,ALLOCATABLE,DIMENSION(:)::A
READ*,M
ALLOCATE(A(M))
READ*,A
CALL BUBBLESORT(M,A)

ALICE=0
BOB=0
DO I=1,M,2
 ALICE=ALICE+A(I)
END DO
DO I=2,M,2
 BOB=BOB+A(I)
END DO
PRINT"(I0)",ALICE-BOB

CONTAINS

subroutine bubblesort(N,array)
  integer,intent(in)::N
  INTEGER,intent(inout)::array(1:N)
  integer::i,j
  INTEGER::t
   
  do i=1,N-1
     do j=i+1,N
        if(array(i) < array(j))then
           t=array(i)
           array(i)=array(j)
           array(j)=t
        end if
     end do
  end do

  return
end subroutine bubblesort
END