program main
  implicit none
  integer i,N,al,av
  integer,allocatable :: d(:)
  read(*, *) N
  allocate(d(N))
  read(*, *) (d(i), i = 1,N)

  call qsort(d)

  write(*, *) abs(d(N/2)-d(N/2+1))

  contains

  recursive subroutine qsort(a)
  implicit none
  integer,intent(inout) :: a(:)
  integer::i,j,toobig,toosmall,pv,n
  n = size(a)
  i = 1
  j = n
  pv = a((i+j)/2)
  do
     do
       if (a(i) < pv) then
         i = i+1
       else
         exit
       end if
     end do
     do
       if(a(j) > pv) then
         j = j-1
       else
         exit
       end if
     end do
     if (i>=j) then
       exit
     else
       toobig = a(j)
       toosmall = a(i)
       a(i) = toobig
       a(j) = toosmall
       i = i+1
       j = j-1
     end if
   end do
   if (i > 2) then
     call qsort(a(1:i-1))
   end if
   if (j < n-1) then
     call qsort(a(j+1:n))
   end if
  end subroutine qsort
end program main
