Problem:
 Score : 300 points    Problem Statement Takahashi made N problems for competitive programming.
The problems are numbered 1 to N , and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).  He is dividing the problems into two categories by choosing an integer K , as follows:   A problem with difficulty K or higher will be for ARCs .  A problem with difficulty lower than K will be for ABCs .   How many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?      Problem Statement  2 \leq N \leq 10^5  N is an even number.  1 \leq d_i \leq 10^5  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  d_1  d_2  ...  d_N       Output Print the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.        Sample Input 1 6
9 1 4 4 6 7      Sample Output 1 2  If we choose K=5 or 6 , Problem 1 , 5 , and 6 will be for ARCs, Problem 2 , 3 , and 4 will be for ABCs, and the objective is achieved.
Thus, the answer is 2 .       Sample Input 2 8
9 1 14 5 5 4 4 14      Sample Output 2 0  There may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.       Sample Input 3 14
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1      Sample Output 3 42685

Solution (Python):


N = int(input())
a = sorted(map(int, input().split()))
harf = int(N / 2)
if (a[harf - 1] == a[harf]):
    print(0)
else:
    print(a[harf] - a[harf-1])

Solution (Python):
n=int(input())
A=sorted(list(map(int,input().split())))
if n%2==1:
  print(0)
else:
  print(A[n//2]-A[n//2-1] )

Solution (Python):
input()
d = [int(i) for i in input().split(' ')]
d = sorted(d)
N = len(d)
l, h = d[:N // 2], d[N // 2:]
ml = max(l)
mh = min(h)
print(mh - ml)

Solution (Python):
N = int(input())
d = list(map(int, input().split(' ')))
d.sort()

print( d[N//2] - d[N//2 - 1] )

Solution (Python):
n = int(input())
dd = list(map(int, input().split()))
ds = list(sorted(dd))
a, b = ds[n // 2], ds[n // 2 - 1]
print(a - b)

Solution (Python):
s = int(input())
list = [int(n) for n in input().split()]

s_l = sorted(list)
print(s_l[s//2] - s_l[s//2 - 1])

Solution (Python):
s = int(input())
list = [int(n) for n in input().split()]

print(sorted(list)[s//2] - sorted(list)[s//2 - 1])

Solution (Python):
s = int(input())
list = [int(n) for n in input().split()]

temp1 = []
temp2 = []
sorted_list = sorted(list)

for i in range(s//2):
    temp1.append(sorted_list[i])

for i in range(s//2, s):
    temp2.append(sorted_list[i])

if temp1[-1] >= temp2[0]:
    print(0)
else:
    print(temp2[0] - temp1[-1])

Solution (Python):
import statistics

n = int(input())
d = list(map(int, input().split()))

median = statistics.median(d)
print(statistics.median_high(d) - statistics.median_low(d))

Solution (Python):
n = int(input())
d = sorted([int(i) for i in input().split()])
print(d[n // 2] - d[n // 2 - 1])

Solution (Python):
n = int(input())
d = list(map(int, input().split()))
d.sort()
if n % 2 == 1:
    print(0)
    exit()
half = n // 2
if d[half] == d[half - 1]:
    print(0)
    exit()
else:
    print(d[half] - d[half - 1])

Solution (Python):
n = int(input())
data = [int(i) for i in input().split(" ")]
data.sort()

print(data[n//2] - data[n//2-1])

Solution (Python):
n=int(input())
p=sorted(map(int, input().split()))
print(p[n//2]-p[n//2-1])

Solution (Python):
N = input()
row = list(map(int,input().split()))
row.sort()
middle = len(row) // 2
print(row[middle] - row[middle - 1])

Solution (Python):
n = int(input())
p = [int(i) for i in input().split(" ")]
p = sorted(p)
print(p[n//2]  - p[n//2 - 1] )

Solution (Python):
N = int(input())
d = list(map(int,input().split()))
d.sort()
mid_N = int(N / 2)
print(d[mid_N] - d[mid_N - 1])

Solution (Python):
N = int(input())
d = list(map(int, input().split()))

d.sort()
a = d[N // 2 - 1]
b = d[N // 2]

print(b - a)

Solution (Python):
n=int(input())
d=list(map(int,input().split()))
d.sort()
count=0
R=d[n//2-1]
L=d[n//2]
if L==R:
    count=0
else:
    count=L-R
print(count)

Solution (Python):
n=int(input())
l=sorted(list(map(int,input().split())))
print(l[n//2]-l[n//2-1])

Solution (Python):
a=int(input())
n=sorted(list(map(int,input().split())))
print(n[a//2]-n[a//2-1])

Solution (Python):
N =int(input())
list = list(map(int, input().split()))
list.sort()
print(list[N//2]-list[N//2-1])

Solution (Python):


import numpy as np

n = int(input())
p = list(map(int,input().split()))

p.sort()

print(p[n//2]-p[n//2-1])

Solution (Python):
N = int(input())
d = input().split()
d = list(map(int,d))

d.sort()

ans = d[N//2] - d[(N//2)-1]
print(ans)

Solution (Python):
n = int(input())
d = list(map(int, input().split()))
d.sort()

print(d[(len(d))//2]-d[(len(d)-1)//2])

Solution (Python):
N = int(input())
A = sorted(list(map(int,input().split())))

print(A[N // 2] - A[N // 2 - 1])

Solution (Python):
n=int(input())
d=sorted(list(map(int,input().split())))
print(d[int(n/2)]-d[int(n/2-1)])

Solution (Python):
def solve():
  n = int(input())
  p = list(int(i) for i in input().split())
  p.sort()
  
  ans = p[n//2]-p[-1 + n//2]
  print(ans)
solve()

Solution (Python):
n=int(input())
d=list(map(int,input().split()))
if n%2==1:
  print(0)
else:
  d.sort()
  print(d[n//2]-d[n//2-1])

Solution (Python):
def resolve():
    n=int(input())
    d=list(map(int,input().split()))
    ss=sorted(d)
    ans=0
    if n%2==0:
        m=n//2-1
        if ss[m]==ss[m+1]:
            ans=0
        else:
            ans=ss[m+1]-ss[m]
    else:
        ans=0
    print(ans)
    
resolve()

Solution (Python):
N = int(input())
d = sorted(list(map(int, input().split())))
print(d[N//2]-d[N//2-1])

Solution (Python):
N, d_list = int(input()), list(map(int, input().split()))
print(max(sorted(d_list)[N // 2 - 1: N // 2 + 1]) - min(sorted(d_list)[N // 2 - 1: N // 2 + 1]))

Solution (Python):
N = int(input())

D = [int(i) for i in input().split()]

D2 = sorted(D)
A = D2[N//2-1]
B = D2[N//2]
print(abs(A-B))

Solution (Python):
n=int(input())
ls=list(map(int,input().split()))
ls.sort()
if n%2==1:
    print(0)
else:
    print(ls[n//2]-ls[n//2-1])

Solution (Python):
N=int(input())
NN=N//2
L=list(map(int,input().split()))
L.sort()
L+=[L[-1]+111]
j=-1
K=0
ans=0
for K in range(1,L[-2]+1):
  while L[j+1]<=K:
    j+=1
    
  if j+1==NN:
    ans+=1
print(ans)

Solution (Python):
N=int(input())
d=[int(x) for x in input().split()]

d.sort()
print(d[N//2]-d[N//2-1])

Solution (Python):
N = int(input())
dlist = list(map(int, input().split()))
dlist.sort()
L = dlist[N // 2 - 1]
R = dlist[N // 2]
print(R-L)

Solution (Python):
N = int(input())
d = list(map(int, input().split()))
d.sort()
print(d[N//2] - d[N//2 - 1])

Solution (Python):
import bisect

n = int(input())
d = [int(x) for x in input().split()]

d.sort()
ans = 0

for k in range(1, max(d)+1):
  i = bisect.bisect_left(d,k)
  if i == n - i:
    ans += 1
    
print(ans)

Solution (Python):
N=int(int(input())/2)
a=sorted(list(map(int,input().split())))
print(int(a[N])-int(a[N-1]))

Solution (Python):
N = int(input())
d = list(map(int, input().split()))

d.sort()
left = d[int(N/2-1)]
right = d[int(N/2)]

dif = right - left

print(dif)

Solution (Python):
N = int(input())
d_list = [int(d) for d in input().split()]

d_list = sorted(d_list)


d_1 = d_list[len(d_list)//2-1]
d_2 = d_list[len(d_list)//2]
print(d_2-d_1)

Solution (Python):
N = int(input())
d = list(map(int,input().split()))
d.sort()
m = N//2
if d[m] == d[m-1]:
    print(0)
else:
    print(d[m]-d[m-1])

Solution (Python):
N = int(input())
DDD = list(map(int, input().split()))

DDD.sort()

mannaka = N//2
print(DDD[N//2] - DDD[(N//2)-1])

Solution (Python):
n = int(input())
d = list(map(int,input().split()))
d.sort()
while len(d) > 0:
        x = d.pop()
        y = d.pop(0)
print(x - y)

Solution (Python):
n=int(input())
hoge=list(map(int,input().split()))
hoge.sort()
print(hoge[n//2]-hoge[n//2-1])

Solution (Python):


n=int(raw_input())
d=map(int,raw_input().split())
d.sort()
print d[n/2]-d[n/2-1]

Solution (Python):
n = int(input())
d = list(map(int,input().split()))

count = 0

if n % 2 == 0:
    d.sort()
    tmp = n  // 2

    if d[tmp-1] == d[tmp]:
        print(0)

    else:
        print(d[tmp]-d[tmp-1])

else:
    print(0)

Solution (Python):
n=int(input())
d=list(map(int,input().split()))
d.sort()
print(d[n//2]-d[n//2-1])

Solution (Python):
n = int(input())
d = list(map(int, input().split()))

d.sort()

m = n // 2

if d[m] == d[m-1]:
    print(0)
else:
    print(d[m] - d[m-1])

Solution (Python):
n = int(input())
d = sorted([int(_) for _ in input().split()])
print(d[n // 2] - d[n // 2 - 1])

Solution (Python):
n=int(input())
d=list(map(int,input().split()))
d.sort()
print(d[n//2]-d[n//2-1])

Solution (Python):
n=int(input())//2-1
d=[int(i) for i in input().split()]
d.sort()
abc,arc=d[n],d[n+1]
print(arc-abc if arc!=abc else 0)

Solution (Python):
import numpy as np
n = int(input())
d = list(map(int, input().split()))
d = np.sort(d)
print(max(d[n//2] - d[n//2-1], 0))

Solution (Python):
n=int(input())
p=list(map(int,input().split()))
p.sort()
print(p[n//2]-p[n//2-1])

Solution (Python):
n = int(input())
d = list(map(int, input().split()))
d.sort()
print(max(d[n//2] - d[n//2-1], 0))

Solution (Python):
N = int(input())
d = sorted(map(int, input().split()))
K = d[int(N/2)]-d[int(N/2)-1]
print(K)

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
print(a[n//2]-a[n//2-1])

Solution (Python):
n=int(input())
d=[int(a) for a in input().split()]

d.sort()

print(d[n//2]-d[n//2-1])

Solution (Python):
n = int(input())
d = list(map(int, input().split()))
d.sort()
print(d[n//2] - d[n//2-1])

Solution (Python):
n=int(input())
l = sorted(list(map(int, input().split())))
print(l[n//2] - l[n//2-1])

Solution (Python):
n=int(input())
li=list(map(int,input().split()))
li.sort()
k=n//2
print(li[k]-li[k-1])

Solution (Python):
N = int(input())
D = list(map(int, input().split()))

d = sorted(D)
mi_l, mi_h = d[N // 2 - 1], d[N // 2]

print(max(0, mi_h - mi_l))

Solution (Python):
n = input()
l = sorted([int(x) for x in raw_input().split()])
print l[n/2] - l[n/2-1]

Solution (Python):
n = int(input())
arr = list(map(int, input().split()))

arr.sort()
high = arr[n // 2]
low = arr[n // 2 - 1]

print(high - low)

Solution (Python):
n = int(input())
ds = [int(c) for c in input().split()]
ds.sort()
m = n // 2
print(ds[m] - ds[m-1])

Solution (Python):
n=int(input())
dlist=[int(d) for d in input().split()]

dlist.sort()

left=dlist[n//2-1]
right=dlist[n//2]
print(max(right-left,0))

Solution (Python):
n=int(input())
d=list(map(int,input().split()))
d.sort()
print(d[int(n/2)]-d[int(n/2-1)])

Solution (Python):
n = input()
N = input()
N = N.split(" ")
Ni = []
n = int(n)
for i in N:
    Ni.append(int(i))
l = sorted(Ni)
print(l[(n//2)] - l[(n//2)-1])

Solution (Python):
import numpy as np

N = int(input())
d = list(map(int, input().split()))

arr_d = np.array(d)

d_sorted = np.sort(arr_d)

n1 = int(N / 2)
n2 = int(N / 2 - 1)

ans = d_sorted[n1] - d_sorted[n2]

print(ans)

Solution (Python):
n = int(input())
d_list = list(map(int, input().split()))
d_list.sort()
if n%2 == 0:
    mid = int(n/2)
    print(d_list[mid]-d_list[mid-1])
else:
    print(0)

Solution (Python):
N=int(input())
d=list(map(int,input().split()))
d.sort()
print(d[N//2]-d[(N//2)-1])

Solution (Python):
n=int(input())
a=input().split()
for i in range(0,n):
  a[i]=int(a[i])
a.sort()
print(a[n//2]-a[n//2-1])

Solution (Python):
N=int(input())
d=list(map(int,input().split()))

d.sort()

num=d[N//2]-d[N//2-1]

print(num)

Solution (Python):
N = int(input())
d = list(map(int, input().split()))
mid_N = int(N/2)
d_sorted = sorted(d)
print(d_sorted[mid_N] - d_sorted[mid_N-1])

Solution (Python):
n = int(input())
*d, = map(int,input().split())

d.sort()
print(d[(len(d)//2)] - d[len(d)//2-1])

Solution (Python):


N = int(int(input())/2)
d = list(map(int, input().split()))
d.sort()
print(d[N]-d[N-1])

Solution (Python):
num_input = int(input())
input_arr = [int(x) for x in input().split()]

max_input = max(input_arr)
count = 0
second_arr =[]
first_arr = []
sorted_arr = sorted(input_arr)
ans = sorted_arr[int(num_input/2)] - sorted_arr[int(num_input/2)-1]
print(ans)

Solution (Python):
N = int(input())
d = [int(i) for i in input().split()]
d.sort()

print(d[N//2] - d[N//2 - 1])

Solution (Python):
n = int(input())
questions = sorted(list(map(int, input().split())))

half = int(n/2)
bottom = questions[half-1]
top = questions[half]

print(top - bottom)

Solution (Python):
a = int(input())
ar = list(map(int,input().split(" ")))
ar.sort()
lr = ar[0:a//2]
hr = ar[a//2:a]
print(min(hr)-max(lr))

Solution (Python):
n = int(input())
p = list(map(int, input().split()))
p.sort()
print(p[n//2] - p[(n//2)-1])

Solution (Python):
N=input()
D=map(int,raw_input().split())
D.sort()
m0=D[len(D)/2-1]
m1=D[len(D)/2]
print(m1-m0)

Solution (Python):
N=int(input())
d=list(map(int,input().split()))

d.sort()

print(d[N//2]-d[N//2-1])

Solution (Python):
N = int(input())
d = [int(i) for i in input().split()]
e = sorted(d)
print(e[N//2] - e[N//2 - 1])

Solution (Python):
n=int(input())
a=list(map(int,input().split( )))
if n%2!=0:
  print(0)
else:
  a.sort()
  i=n//2-1
  count=a[i+1]-a[i]
  print(count)

Solution (Python):
N = int(input())
D = list(map(int, input().split()))

D.sort()
ans = D[N//2] - D[N//2 - 1]
print(ans)

Solution (Python):
import sys
import bisect
input = sys.stdin.readline

N = int(input())
L = [int(v) for v in input().split()]
L.sort()

ans = 0
n = N // 2
for v in range(2, L[-1] + 1):
    if n == bisect.bisect_left(L, v):
        ans += 1
        
print(ans)

Solution (Python):
n =int(input())
d = list(map(int,input().split()))

d_sorted = sorted(d)
center = n//2-1
print(d_sorted[center+1] - d_sorted[center])

Solution (Python):
a = int(input())
b = [int(i) for i in input().split()]
b.sort()
if b[a // 2 - 1] == b[a // 2]:
    print(0)
else:
    print(b[a // 2] - b[a // 2 - 1])

Solution (Python):
def calc(ds) -> int:
  ds = sorted(ds)
  half = len(ds) // 2
  lower_d = ds[half - 1]
  higher_d = ds[half]
  
  return higher_d - lower_d

_ = input()
numbers_str = input()
result = calc([int(n) for n in numbers_str.split(' ')])
print(result)

Solution (Python):
n = int(input())
if n % 2 == 1:
  print(0)
  exit()
d = list(map(int, input().split()))
d = sorted(d)
if d[n//2] - d[n//2-1] == 0:
  print(0)
  exit()
print(d[n//2] - d[n//2-1])

Solution (Python):
def prob_c():
    n = int(input())
    d_list = [int(a) for a in input().split()]
    d_list.sort()
    return d_list[int(n/2 + 0.1)] - d_list[int(n/2 + 0.1) - 1]


b = prob_c()
print(str(b))

Solution (Python):
n = int(input())
d = list(map(int,input().split()))
d.sort()
ans = d[int(n/2)] - d[int(n/2)-1]
print(ans)

Solution (Python):
n = int(input())
d = list(map(int,input().split()))
d.sort()
ans = d[int(n/2)] - d[int(n/2)-1]
print(ans)

Solution (Python):
n = int(input())
arr =  list(map(int, input().split() ))

arr.sort()
print(arr[n//2] - arr[n//2-1])

Solution (Python):
from collections import Counter

N = int(input())

c = Counter(list(map(int, input().split())))
D = sorted(list(c.keys()))

x = 0
s = 0
a = 0
b = N
for k in D:
    a += c[k]
    b = N - a
    if a == b:
        x = k
    elif a > b and x > 0:
        s = k - x
        break

print(s)

Solution (Python):


N=int(input())

d=list(map(int,input().split()))
d.sort()
print(d[int(N/2)]-d[int((N/2))-1])

Solution (Python):
N = int(input())
D = list(map(int, input().split()))
D.sort()
M = int(N/2)

if D[M-1] == D[M]:
	print(0)
else:
	print(D[M]-D[M-1])

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())
d = list(map(int,stdin.readline().split()))

d.sort()
print(d[N//2]-d[N//2-1])

Solution (Python):
from collections import Counter
n = int(input())
d_array = [int(x) for x in input().split()]
d_counter = Counter(d_array)

max_d = max(d_array)
tmp = 0
cnt = 0
for i in range(max_d):
    tmp += d_counter[i]
    if tmp == n//2:
        cnt += 1
print(cnt)

Solution (Python):
N = int(input())
d = [int(_) for _ in input().split()]
d = sorted(d)
print(d[N//2]-d[N//2-1])

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    a = sorted(LI())
    i = n // 2 - 1

    return a[i+1] - a[i]


print(main())

Solution (Python):
from collections import Counter
from sys import exit
N, = list(map(int,input().split()))
d = list(map(int,input().split()))
c = Counter(d)
ks = list(c.keys())
ks.sort()
s = 0
for i,k in enumerate(ks[:N-1]):
  s += c[k]
  if s==N//2:
    print(ks[i+1]-k)
    exit(0)
print(0)

Solution (Python):
n=int(input())
d=[int(i) for i in input().split()]


d.sort()


print(d[n//2]-d[n//2-1])

Solution (Python):
N = int(input())
d = [int(x) for x in input().split()]
d.sort()
print(d[N//2]-d[N//2-1])

Solution (Python):
N = int(input())
d = [int(_) for _ in input().split()]
ans = 0
d = sorted(d)

if d[N//2-1] != d[N//2]:
    ans = d[N//2] - d[N//2 - 1] 

print(ans)

Solution (Python):
n=int(input())
d=[int(x) for x in input().split()]

d.sort()
print(d[n//2]-d[n//2-1])

Solution (Python):



""" convenient functions




"""

import sys
sys.setrecursionlimit(10**7)
from itertools import accumulate, combinations, permutations, product 

from math import factorial, ceil, floor
def factorize(n):
    """return the factors of the Arg and count of each factor
    
    Args:
        n (long): number to be resolved into factors
    
    Returns:
        list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
    """
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
def combinations_count(n, r):
    """Return the number of selecting r pieces of items from n kinds of items.
    
    Args:
        n (long): number
        r (long): number
    
    Raises:
        Exception: not defined when n or r is negative
    
    Returns:
        long: number
    """
    
    if n < 0 or r < 0:
        raise Exception('combinations_count(n, r) not defined when n or r is negative')
    if n - r < r: r = n - r
    if r < 0: return 0
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result
def combinations_with_replacement_count(n, r):
    """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
    
    Args:
        n (long): number
        r (long): number
    
    Raises:
        Exception: not defined when n or r is negative
    
    Returns:
        long: number
    """
    if n < 0 or r < 0:
        raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
    elif n == 0:
        return 1
    else:
        return combinations_count(n + r - 1, r)
from bisect import bisect_left, bisect_right
from collections import deque, Counter, defaultdict 
from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest 
from copy import deepcopy, copy 
from operator import itemgetter


from functools import reduce
def chmin(x, y):
    """change minimum
    if x > y, x = y and return (x, True).
    convenient when solving problems of dp[i]
    
    Args:
        x (long): current minimum value
        y (long): potential minimum value
    
    Returns:
        (x, bool): (x, True) when updated, else (x, False)
    """
    if x > y:
        x = y
        return (x, True)
    else:
        return (x, False)
def chmax(x, y):
    """change maximum
    if x < y, x = y and return (x, True).
    convenient when solving problems of dp[i]
    
    Args:
        x (long): current maximum value
        y (long): potential maximum value
    
    Returns:
        (x, bool): (x, True) when updated, else (x, False)
    """
    if x < y:
        x = y
        return (x, True)
    else:
        return (x, False)

from fractions import gcd 
def gcds(numbers):
    return reduce(gcd, numbers)
def lcm(x, y):
    return (x * y) // gcd(x, y)
def lcms(numbers):
    return reduce(lcm, numbers, 1)



INF = 10 ** 18
MOD = 10 ** 9 + 7
modpow = lambda a, n, p = MOD: pow(a, n, p) 
def modinv(a, p = MOD):
    
    
    return modpow(a, p-2, p)
def modinv_list(n, p = MOD):
    if n <= 1:
        return [0,1][:n+1]
    else:
        inv_t = [0,1]
        for i in range(2, n+1):
            inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
        return inv_t
def modfactorial_list(n, p = MOD):
    if n == 0:
        return [1]
    else:
        l = [0] * (n+1)
        tmp = 1
        for i in range(1, n+1):
            tmp = tmp * i % p
            l[i] = tmp
        return l
def modcomb(n, k, fac_list = [], p = MOD):
    
    
    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    if len(fac_list) <= n:
        a = factorial(n) % p
        b = factorial(k) % p
        c = factorial(n-k) % p
    else:
        a = fac_list[n]
        b = fac_list[k]
        c = fac_list[n-k]
    return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
def modadd(a, b, p = MOD):
    return (a + b) % MOD
def modsub(a, b, p = MOD):
    return (a - b) % p
def modmul(a, b, p = MOD):
    return ((a % p) * (b % p)) % p
def moddiv(a, b, p = MOD):
    return modmul(a, modpow(b, p-2, p))

""" initialize variables and set inputs

    
    

    
    
    
    
    

    
    
    
    

    
    
"""


r = lambda: sys.stdin.readline().strip()
r_int = lambda: int(r())
R = lambda: list(map(int, r().split()))
Rfloat = lambda: list(map(float, r().split()))
Rtuple = lambda: tuple(map(int, r().split()))
Rmap = lambda: map(int, r().split())

""" how to treat input







"""




N = int(r())
D = R()
D.sort()

mid_left = N // 2 - 1
mid_right = mid_left + 1
print(D[mid_right] - D[mid_left])




"""memo: how to use defaultdict of list

Dic = defaultdict(list)

Dic[x].append(y)

for k, v in Dic.items():
"""

Solution (Python):
n = int(raw_input())
a = sorted(map(int,raw_input().split()))
x = a[n/2]
y = a[n/2-1]
print x-y

Solution (Python):
n=int(input())
l=[int(s) for s in input().split()]
cnt=0
l.sort()
print(l[n//2]-l[n//2-1])

Solution (Python):
n = int(input())
D = list(map(int, input().split()))
D.sort()
n1 = n // 2
n0 = n1 - 1

if D[n0] == D[n1]:
    print(0)
else:
    print(-(D[n0] - D[n1]))

Solution (Python):
n = int(input())
A = sorted(list(map(int, input().split())))
leng = len(A)//2
print(A[leng] - A[leng-1])

Solution (Python):
n = int(input())//2
li = list(map(int,input().split()))
li.sort()
print(li[n]-li[n-1])

Solution (Python):
l = input().split()
N = int(l[0])
D = list(map(int, input().split()))

D.sort()
N2 = N // 2
l = D[N2 - 1]
r = D[N2]
ans = r - l
print(ans)

Solution (Python):
n=int(input())
ls=list(map(int,input().split()))
ls.sort()

print(ls[n//2]-ls[n//2-1])

Solution (Python):
n = int(input())
d = [int(i) for i in input().split()]

d.sort()

a = n // 2

print(d[a] - d[a-1])

Solution (Python):
N = int(input())
D = [int(i) for i in input().split()]
cnt = 0
Ds = sorted(D)
dl = len(Ds)
ans = Ds[round(dl/2)] - Ds[round(dl/2) - 1]
print(ans)

Solution (Python):

import sys


def solve(N: int, d: "List[int]"):
    d.sort()
    print(d[N//2] - d[N//2-1])

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    d = [ int(next(tokens)) for _ in range(N) ]  
    solve(N, d)

if __name__ == '__main__':
    main()

Solution (Python):
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    D = sorted(LIST())
    print(D[N//2] - D[N//2-1])

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
d_list = list(map(int, input().split()))

d_list.sort()

print(d_list[N//2] - d_list[N//2 - 1])

Solution (Python):
input1 =int(input())
L = list(map(int, input().split()))
L.sort()
low = L[int(input1/2 -1)]
high = L[int(input1/2)]
number = high - low
print(number)

Solution (Python):
n = int(input())
k = int(n/2)
d = list(map(int,input().split()))
d.sort()
print(d[k]-d[k-1])

Solution (Python):
n=int(input())
p=list(map(int,input().split()))
p.sort()
n1=int(n/2)
if p[n1-1]==p[n1]:
    print (0)
else:
    start=p[n1-1]
    end=p[n1]
    ans=end-start
    print(ans)

Solution (Python):

n = int(input())
ds = list(map(int, input().split()))

ds.sort()

i_min = int(n / 2) -1
i_max = int(n / 2)


k_min = ds[i_min]
k_max = ds[i_max]

ks = range(k_min, k_max)

print(len(ks))

Solution (Python):




 
from collections import* 
from fractions import gcd
from functools import* 
from itertools import* 
from operator import mul,itemgetter
from bisect import* 
from heapq import* 
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)

 
def main():
    n,*a=map(int,open(0).read().split())
    p=sorted(a)
    print(p[n//2]-p[n//2-1])

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
pre = [int(i) for i in input().split()]
pre.sort()
xx = pre[int(n / 2 - 1)]
yy = pre[int(n / 2)]
ans = 0
for i in range(xx + 1, yy + 1) :
    ans += 1
print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
d=sorted(map(int,input().split()))
print(d[n//2]-d[n//2-1])

Solution (Python):
from bisect import bisect_right
N = int(input())
D = sorted(list(map(int, input().split())))

ans = 0
for k in range(10 ** 5 + 1):
    ri = bisect_right(D, k)
    if ri == N // 2:
        ans += 1

print(ans)

Solution (Python):
n = int(input())
s = [int(i) for i in input().split()]
a = len(s)/2
s.sort()
print(s[int((len(s)/2))]-s[int((len(s)/2)-1)])

Solution (Python):
N = int(input())
D = [int(_) for _ in input().split()]

D.sort()
M = N//2
print(D[M] - D[M-1])

Solution (Python):

n = int(input())
d = list(map(int, input().split()))
d.sort()
ans = d[int(n/2)] - d[int(n/2-1)]
print(ans)

Solution (Python):
n=int(input())
d=list(map(int,input().split()))
d=sorted(d)
print(d[n//2]-d[n//2-1])

Solution (Python):



def main():
    n = int(input())
    d = sorted(list(map(int, input().split())))
    print(d[n // 2] - d[n // 2 - 1])


if __name__ == '__main__':
    main()

Solution (Python):
def solve(n, d):
    d = sorted(d)
    n2 = n//2
    return d[n2] - d[n2-1]

n = int(input())
d = list(map(int, input().split()))
print(solve(n, d))

Solution (Python):
n = int(input())
d = list(map(int,input().split()))
d.sort()

print(d[n//2]-d[n//2-1])

Solution (Python):
n = int(input())
d = list(map(int, input().split()))
d.sort()
ans = d[n // 2] - d[n // 2 - 1]

if n % 2 != 0:
    ans = 0
print(ans)

Solution (Python):
N = int(input())
d = list(map(int, input().split()))
d.sort()
print(d[N//2] - d[N//2 - 1])

Solution (Python):
n=int(input())
d=list(map(int,input().split()))
d.sort()
if d[n//2-1]==d[n//2]:
  print(0)
else:
  print(d[n//2]-d[n//2-1])

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
a.sort()
print(a[n // 2] - a[n // 2 - 1] if n % 2 == 0 else 0)

Solution (Python):
n = int(input())
d = [int(i) for i in input().split()]

d.sort()
r = d[n // 2] - d[n // 2 - 1] 
print(r)

Solution (Python):
N = int(input())
*D, = map(int, input().split())
D = sorted(D)
print(D[N//2] - D[N//2-1])

Solution (Python):
n,*l=map(int,open(0).read().split());l.sort();print(l[n//2]-l[n//2-1])

Solution (Python):
n,*l=map(int,open(0).read().split());l.sort();print(l[n//2]-l[n//2-1])

Solution (Python):
n = int(input())
dif = [int(i) for i in input().split()]

dif.sort()

print(dif[n//2] - dif[n//2 -1])

Solution (Python):
N = int(input())
number_list = list(map(int, input().split()))
sorted_number_list = sorted(number_list)
print(sorted_number_list[int(N/2)] - sorted_number_list[int(N/2)-1])

Solution (Python):
N = int(input())
ds = list(map(int, input().split()))

ds.sort()

K_small = ds[N//2-1]
K_big = ds[N//2]

print(K_big - K_small)

Solution (Python):
n = int(input())
d = sorted(list(map(int, input().split())))
print(d[n // 2] - d[n // 2 - 1])

Solution (Python):
N = int(input())
D = sorted(list(map(int, input().split())))

print(D[N // 2] - D[N // 2 - 1])

Solution (Python):
n = int(input())
d = sorted((list(map(int, input().split()))))

if len([i for i in d if d[n // 2 - 1] >= i]) == n // 2:
    print(d[n // 2] - d[n // 2 - 1])
else:
    print(0)

Solution (Python):
n = int(input())
lis = sorted(list(map(int,input().split())))

print(lis[n//2] - lis[n//2 - 1])

Solution (Python):
n = int(input())
D = list(map(int, input().split()))
D.sort()
if n % 2:
    print(0)
else:
    print(D[n // 2] - D[n // 2 - 1])

Solution (Python):
n = int(input())
items = sorted(list(map(int, input().split(' '))))
print(items[int(n / 2)] - items[int(n / 2) - 1])

Solution (Python):
N = int(input())
d = sorted(list(map(int, input().split())))

ans = d[N // 2] - d[N // 2 - 1]
print(ans)

Solution (Python):
N = int(input())
ds = sorted([int(i) for i in input().split()])

print(ds[N//2] - ds[N//2 - 1])

Solution (Python):
n = int(input())
d = list(map(int, input().split()))

list = sorted(d)
print(list[int(n/2 )]- list[int(n/2 -1)])

Solution (Python):
n=int(input())
list=list(map(int,input().split()))
list2=list.sort()

print(list[int(n/2)]-list[int(n/2)-1])

Solution (Python):
n=int(input())
d=list(map(int,input().split()))
d=sorted(d)

print(d[n//2]-d[n//2-1])

Solution (Python):
n=int(input())
l=sorted(map(int,input().split()))
print(l[n//2]-l[n//2-1])

Solution (Python):
N = int(input())
d =[int(i)for i in input().split()]
d.sort()
a,b = d[N//2-1:N//2 +1]
print(max(0,b-a))

Solution (Python):
N = int(input())
d = list(map(int, input().split()))

ans=0
new_d = sorted(d)
hanbun =int(N/2)
K=0
K=new_d[hanbun]
ans=K-new_d[hanbun-1]
print(ans)

Solution (Python):
n = int(input())
ds = list(map(int,input().split()))
ds.sort()
print(ds[n//2]-ds[n//2-1])

Solution (Python):
n=int(input())
d=list(map(int, input().split()))
d=sorted(d)
answer=0
t=int(len(d)/2)
answer=d[t]-d[t-1]
print(answer)