program answer
  implicit none
  integer :: i, n, ans
  integer, allocatable :: d(:)
  read(*,*) n
  allocate(d(n))
  read(*,*) d
  call msort(d)

  ans=d(n/2+1)-d(n/2)
  write(*,*) ans

  deallocate(d)
  stop
contains
  recursive subroutine msort(array)
    implicit none
    integer :: i, j, k, n, mid, array(:)
    integer, allocatable :: tmp(:)
    n=size(array)
    allocate(tmp(n))
    if(n==1) then
       return
    end if
    mid=n/2
    call msort(array(1:mid))
    call msort(array(mid+1:n))
    tmp=array
    do i = mid+1, n
       tmp(i)=array(mid+1+n-i)
    end do
    i=1
    j=n
    do k = 1, n
       if(tmp(i)>=tmp(j)) then
          array(k)=tmp(j)
          j=j-1
       else
          array(k)=tmp(i)
          i=i+1
       end if
    end do
    deallocate(tmp)
    return
   end subroutine msort
 end program answer