program main
  implicit none
  integer(8) i,N,al,av
  integer(8),allocatable :: d(:)
  !read(*, *) (L(i), i = 1,N)
  read(*, *) N
  allocate(d(N))
  read(*, *) (d(i), i = 1,N)
  do i = 1,N/2+1
      al = minloc(d(i:N),1)
      av = minval(d(i:N))
      d(al+i-1) = d(i)
      !write(*,*)d(i),d(al)
      d(i) = av
      !write(*,*) d(i)
      !write(*, *) d
  end do
  !write(*, *) d


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