program cut
  implicit none
  integer(8) :: n, ans
  integer(8),allocatable :: d(:)

  read *, n
  allocate(d(n))
  read *, d
  d = qsort(d)
  ans = d(n/2+1)-d(n/2)
  print '(i0)', ans
  stop

contains
  recursive function qsort(a) result(sorted)
    implicit none
    integer(8):: countl,countg, pivot, i, n
    integer(8),intent(in):: a(:)
    integer(8),allocatable:: sorted(:),less(:),great(:)

    n = size(a)
    allocate(sorted(n))
    if (n <= 1) then
      sorted = a
    else
      sorted = 0
      countl = 1
      countg = n
      pivot = a(1)
      do i =2, n
        if (pivot >= a(i)) then
          sorted(countl) = a(i)
          countl = countl + 1
        else
          sorted(countg) = a(i)
          countg = countg - 1
        end if
      end do
      allocate(less(countl-1),great(n-countg))
      less = sorted(1:countl - 1)
      great = sorted(countg+1:n)
      sorted(1:countl-1) = qsort(less)
      sorted(countl) = pivot
      sorted(countg+1:n) = qsort(great)
    end if
  end function
end program cut
