program test
implicit none
integer::i,j,n,work,k,ans
integer,allocatable::a(:)
read(*,*)n
allocate(a(n))
k=n/2
read(*,*)(a(i), i=1,n)
  do i=1,n-1
    do j=i+1,n
      if(a(i) .lt. a(j)) then
        work=a(i)
        a(i)=a(j)
        a(j)=work
      end if
    end do
  end do
ans=a(k)-a(k+1)
print*,ans
end program test