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())
d = list(map(int, input().split()))
d_s = sorted(d)
print(d_s[len(d)//2] - d_s[len(d)//2 - 1])

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

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

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




print(max(0, a[n//2] - a[n//2-1]))

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

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

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

Solution (Python):


def main(N, d):
    d.sort()
    upper = N // 2
    lower = N // 2 -1
    ans = d[upper] - d[lower]
    return ans

if __name__ == '__main__':
    N = int(input())
    d = list(map(int, input().split()))
    print(main(N, d))

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

print(d)

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

E = sorted(D)

if N%2 == 0:
    a = E[N//2-1]
    b = E[N//2]
    
    answer = b - a
else:
    answer = 0
print(answer)

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 = [int(i) for i in input().split()]
k = [0]*100010
for i in d:
    k[i] += 1

for i in range(100010):
    k[i] += k[i-1]


print(k.count(N//2))

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

nums.sort()

if n%2==1:
    print(0)
else:
    x=int((n/2)-1)
    y=int(n/2)
    a=nums[x]
    b=nums[y]
    s=b-a
    print(s)

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())
l=list(map(int,input().split()))
l.sort()
print(l[int(n/2)]-l[int(n/2)-1])

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

Solution (Python):

input()
xs = list(sorted(map(int, input().split())))

arc_idx = len(xs)//2
k_upper = xs[arc_idx]
k_lower = xs[arc_idx - 1] + 1

print(max(k_upper - k_lower + 1, 0))

Solution (Python):
max = int(raw_input())

nums = map(int, raw_input().split())
nums.sort()

print nums[max/2] - nums[max/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())
d = sorted([int(e) for e in input().split()])
print(d[n // 2] - d[n // 2 - 1])

Solution (Python):
n = int(input())
d = sorted([int(x) for x in input().split(' ')])
if d[int(n/2)-1] == d[int(n/2)]:
    print(0)
else:
    print(d[int(n/2)] - d[int(n/2)-1])

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

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

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

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

ds.sort()

small = ds[N//2-1]
big = ds[N//2]

print(big - small)

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

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

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

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

ans = D[int(N/2)] - D[int((N/2) - 1)]

print(ans)

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

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

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

Solution (Python):
def check(N, d):
    numList = d
    numList.sort()
    
    if N % 2 != 0:
        print(0)
    else:
        print(numList[int(len(numList)/2)] - numList[int(len(numList)/2-1)])

N = int(input())
d = [int(i) for i in input().split()]
check(N, d)

Solution (Python):
def check():
    N = int(input())
    numList = list(map(int, input().split(" ")))
    numList.sort()
    
    if N % 2 != 0:
        print(0)
    else:
        print(numList[int(len(numList)/2)] - numList[int(len(numList)/2-1)])

check()

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

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

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

a=sorted(x)
h=A//2

kotae=a[h]-a[h-1]
print(kotae)

Solution (Python):

N = int(input())
values = sorted([int(i) for i in input().split()])
length = len(values)
mode_diff = values[length//2] - values[length//2 -1]
print(mode_diff)

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

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

print(ans)

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

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

sorted_data = sorted(d)
lower_bd = N // 2 - 1
upper_bd = N // 2
print(sorted_data[upper_bd] - sorted_data[lower_bd])

Solution (Python):
import  numpy   as      np

i_N             =       int(input())
s_d               =       input().split()
i_d             =       np.array(s_d).astype(type(i_N))
i_Counter       =       0
i_d             =       sorted(i_d)

if(i_d[int(len(i_d)/2)-1] < i_d[int(len(i_d)/2)]):
        i_Counter       =       i_d[int(len(i_d)/2)] - i_d[int(len(i_d)/2)-1]
print(i_Counter)

Solution (Python):
def main():
    N = int(input())
    d = [int(a) for a in input().split()]
    d_sort = sorted(d)
    if (d_sort[N//2-1] == d_sort[N//2]):
        print(0)
    else:
        print(d_sort[N//2]-d_sort[N//2-1])

main()

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

if N % 2 == 0:
    middle = N // 2
    if A[middle-1] == A[middle]:
        print("0")
    else:
        print(str(A[middle]-A[middle-1]))
else:
    print("0")

Solution (Python):
n=int(input())
d=list(map(int,input().split()))
d.sort()
s=len(d)//2
print(d[s]-d[s-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):
def main():
    N = input()
    ds = list(map(int, input().split()))
    ans = solve(ds)
    print(ans)


def solve(ds):
    ds = sorted(ds)
    imid = len(ds)//2
    abc_max = ds[imid-1]
    arc_min = ds[imid]

    return arc_min - abc_max


if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
d = list(map(int,input().split()))
ans = 0
d.sort()
        
if len(d) % 2 == 0:
    idx1 = int(len(d)/2)
    idx2 = int((len(d)/2)-1)
    if d[idx1] != d[idx2]:
        ans = d[idx1] - d[idx2]
        
print(ans)

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

d.sort()

if d[n//2-1] == d[n//2]:
    cnt = 0
else:
    cnt = d[n//2] - d[n//2-1]

print(cnt)

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

Solution (Python):
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


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


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

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

def main():
	n = int(input().strip())
	v = list(map(int, input().strip().split()))
	ans = 0
	if len(v) % 2 == 0:
		t = sorted(v)
		ans = t[n//2] - t[n//2 - 1]
	print(ans)

if __name__ == '__main__':
	main()

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())
d = [int(_) for _ in input().split()]

d.sort()

d_l = d[int(N / 2) - 1]
d_r = d[int(N / 2)]

ans = d_r - d_l
print(ans)

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

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

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

Solution (Python):





from sys import stdin






temp = stdin.readline().split()
N = int(temp[0])

data = []
write = stdin.readline().split()
for i in range(N):
    data.append(int(write[i]))

data = sorted(data)

print(data[int(N/2)] - data[int(N/2)-1])

Solution (Python):



n = int(input().split()[0])
d_list = list(map(int, input().split()))

sorted_d_list = sorted(d_list)

if sorted_d_list[int(n/2)-1] == sorted_d_list[int(n/2)]:
    ans = 0
else:
    abc_max = sorted_d_list[int(n/2)-1]
    arc_min = sorted_d_list[int(n/2)]
    k_min = abc_max + 1
    k_max = arc_min

    ans = k_max - k_min + 1

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())
a=[int(i) for i in input().split()]
a.sort()
print(a[int(n/2)]-a[int(n/2)-1])

Solution (Python):
n = int(input())//2
d = sorted(list(map(int,input().split())))
print(d[n]-d[n-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())                   
d = list(map(int,input().split()))

sorted_d = sorted(d)
half = n//2

a = sorted_d[half-1]
b = sorted_d[half]

print(b-a)

Solution (Python):
n = int(input())
lis = list(map(int, input().split()))
lis2 = sorted(lis)
m1 = lis2[n//2-1]
m2 = lis2[n//2]

c = 0
for i in range((m1+1), (m2+1)):
    c += 1
print(c)

Solution (Python):

import sys


def solve(N: int, d: "List[int]"):
    d = sorted(d)
    dl = d[:N//2]
    du = d[N//2:]
    print(du[0] - dl[-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):
n=int(input())
arr=list(map(int,input().split(" ")))
arr.sort()
print(arr[n//2]-arr[n//2-1])

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

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

n = int(N/2)
d.sort()

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

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

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

d.sort()

center = int(n / 2)

diff = d[center] - d[center-1]

print(diff)

Solution (Python):
def main():
    n = int(input())
    d = list(map(int,input().split(' ')))
    d = sorted(d)
    print(d[int(n/2)]-d[int(n/2-1)])
if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
d = list(map(int,input().split()))
d = sorted(d)
k = 0
import math
if n % 2 == 0 and d[math.floor((n-1)/2)] != d[math.ceil((n-1)/2)]:
    k = d[math.ceil((n-1)/2)] - d[math.floor((n-1)/2)]
elif n % 2 == 1 and d[(n-1)/2] != d[(n-1)/2 -1] and d[(n-1)/2] != d[(n-1)/2 + 1]:
    k = 1
else:
    k = 0
    
print(k)

Solution (Python):
X = int (input())
N =[int(i) for i in input().split()]
N.sort()
print(N[int(X/2)]-N[int(X/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):
n=int(input())//2
d=sorted(list(map(int,input().split())))
print(d[n]-d[n-1])

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

dn1=sorted(dn,reverse=True)
dnlen=int(len(dn)/2)
if dn1[dnlen-1] == dn1[dnlen]:
    print(0)
else:
    print(dn1[dnlen -1]-dn1[dnlen])

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

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

a = D[N // 2 - 1]
b = D[N // 2]
if a == b:
    print(0)
    exit()

ans = b - a
print(ans)

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

d_sort = sorted(d)
print(d_sort[int(N/2)]-d_sort[int(N/2-1)])

Solution (Python):

S = input()

N = int(S)

S = input()

D = list(map(int, S.split()))

D = sorted(D)

length = len(D)

length_half = length / 2

print(D[int(length_half)]-D[int(length_half-1)])

Solution (Python):

def BinarySort(N, d, index):
  if index > 0:
    d = BinarySort(N, d, index-1)

  count = [0]*10

  num = []

  for di in d:
    num.append( di // (10**index) % 10)
    count[num[-1]] +=1

  for i in range(9):
    count[i+1] += count[i]
  d_ = [None]*N

  for i in range(N-1, -1, -1):
    count[num[i]] -= 1
    d_[ count[num[i]] ] = d[i]
  
  return d_

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

print( d[N//2] - d[N//2-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())

a=(list(map(int,input().split())))
a.sort()
n=n/2
n=int(n)
n-=1

print(a[n+1]-a[n])

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

if d[-1+b]<d[b]:
    print(d[b]-d[b-1])
else:
    print(0)

Solution (Python):

N = int(input())

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

d.sort()

k = int(N/2)
Ans = d[k] - d[k-1]

print(Ans)

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

d.sort()

mod = N // 2
ans = d[mod] - d[mod-1]

print(ans)

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

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

Solution (Python):
from bisect import bisect

N = int(input())
inputs = sorted([int(i) for i in input().split()])

ans = 0
for i in range(inputs[-1] + 1):
    index = bisect(inputs, i)
    if index == (N // 2):
        ans += 1
    elif index > (N // 2):
        break
print(ans)

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

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

d.sort()

half_len = len(d)//2
l = d[half_len-1]
r = d[half_len]

if (r-l > 0) :
    print(r-l)
else :
    print(0)

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

if __name__ == "__main__":
    C_DividetheProblems()

Solution (Python):
a=int(input())
inp = [int(x) for x in input().split()]
inp.sort()
med=int(len(inp)/2)
print(inp[med]-inp[med-1])

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

a.sort()

m = n // 2
print(a[m] - a[m-1])

Solution (Python):
N = int(input())
D = list(map(int,input().split()))
D.sort()
ans = D[N//2]-D[N//2-1]
if ans < 0:
  ans = 0

print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
k = 0
a = sorted(a)
maxa = a[int(len(a)/2)]
mina = a[int(len(a)/2)-1]+1
if mina > maxa:
    print(0)
else:
    print(maxa-mina+1)

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()

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

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

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

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

Solution (Python):
N = int(input())
d = list(map(int, input().split()))
a = len(d)//2
d.sort()

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

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

a = A[int(N/2 - 1)]
b = A[int(N/2)]

print(b-a)

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, 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 [int(x) for x in sys.stdin.readline().split()]
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 _pf(s): return print(s, flush=True)

N = _I()
D = LI()

D = sorted(D)

mid = len(D)//2

if D[mid-1] == D[mid]:
    
    print(0)
    exit()
else:
    res = D[mid] - D[mid-1]
    print(res)

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

P=sorted(p)

K=P[n//2]-P[n//2-1]

print(K)

Solution (Python):
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
14
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1
'''

def MAIN():
  
  A()


def A():
  num = IN_I()
  lists = IN_L_I()
  lists.sort()

  print(lists[num // 2] - lists[num // 2 - 1])
  return None


def B():
  return None


def C():
  return None


MAIN()

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

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

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

    print(abs(d[N//2-1] - d[N//2]))
    
if __name__ == '__main__':
    main()

Solution (Python):
import math

def main():
    N = int(input())
    difficulty_list = list(map(int, input().split(" ")))
    big_list = sorted(difficulty_list, reverse=True)
    index = int(N/2)
    upper = big_list[index-1]
    lower = big_list[-index]
    count = upper - lower
    print(count)

if __name__ == '__main__':
    main()

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

dlist = list(map(int, input().split()))
d = sorted(dlist)

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()
print(d[int(n/2)]-d[int(n/2)-1])

Solution (Python):
def main06():
    num = int(input())
    data = input().split()
    zyun = []
    for i in data:
        zyun.append(int(i))
    zyun.sort()
    naka = int(num/2)
    result = zyun[naka] - zyun[naka-1]
    print(result)
    
if __name__ == "__main__":
    main06()

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

Solution (Python):
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

N = int(input())
D = list(map(int,input().split()))
D = sorted(D)
left = D[int(N/2)-1]
right = D[int(N/2)]
if left == right:
    print(0)
else:
    print(right-left)

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

d.sort()
print(d[i] - d[i - 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 = 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()))
if N<=2:
    print(abs(d[0]-d[1]))
else:
    d.sort()
    mid = int(N/2)
    print(d[mid]-d[mid-1])

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

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

Solution (Python):
a=int(input())
b=list(map(int,input().split()))
b=sorted((b)[::-1])

print(b[a//2]-b[a//2-1])

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

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

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

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

lst_d.sort()
l = int(len(lst_d) / 2)

low = lst_d[l - 1]
upp = lst_d[l]

print(upp - low)

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

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[int(N/2)]-d[int(N/2-1)])

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

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=sorted(list(map(int,input().split())))
h=len(D)//2
if D[h]==D[h-1]:
  print(0)
else:
  print(D[h]-D[h-1])

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

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

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

t_sort = sorted(t)
print(t_sort[int(n/2)] - t_sort[int(n/2-1)])

Solution (Python):


def solve():
    N = int(input())
    D = list(map(int, input().split()))
    D.sort()

    i = N//2

    if D[i] == D[i-1]:
        print(0)
        return
    
    print(D[i]-D[i-1])

if __name__ == "__main__":
    solve()

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 = sorted(D)

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):
n = int(input())
d = list(map(int,input().split()))

d = sorted(d)

div = len(d)//2 - 1

print(d[div+1] - d[div])

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

d = sorted(d)

div = len(d)//2 - 1
if n%2!=0:
	print(0)
else:
	print(d[div+1] - d[div])

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

Solution (Python):
from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
a.sort()
center = len(a) // 2
cnt = 0
for i in range(1, 10 ** 5 + 1):
    if a[center - 1] < i <= a[center]:
        cnt += 1
print(cnt)

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()
print(d[n//2]-d[n//2-1])

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

L = sorted(L)

ans = abs(L[n//2-1]-L[n//2])
print(ans)

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

m=int(n/2)
        
if L[m-1]==L[m]:
    print(0)
else:
    print(L[m]-L[m-1])

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

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

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

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

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

Solution (Python):


def solve():
    N = int(input())
    D = list(map(int, input().split()))

    D.sort()

    i = N//2

    if D[i] != D[i-1]:
        print(D[i]-D[i-1])
        return
    print(0)

if __name__ == "__main__":
    solve()

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

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

a.sort()
k = int(n/2)    
print(a[k]-a[k-1])

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

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

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

sort_li = sorted(li)


n = int(int(N)/2)

print(sort_li[n] - sort_li[n-1])

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

d = []
s = input().split()
sum = 0
for i in range(n):
  d.append(int(s[i]))
  sum += int(s[i])

d.sort()

if (d[int(n/2)-1]==d[int(n/2)]):
  print(0)
else:
  print(d[int(n/2)] - d[int(n/2)-1])

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

li.sort()
a = li[int(len(li)/2-1)]
b = li[int(len(li)/2 )]

print(b-a)

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

Solution (Python):

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

dif.sort()

ans = dif[int(n/2)] - dif[int(n/2)-1]

print(ans)

Solution (Python):


def solve():
    N = int(input())
    D = list(map(int, input().split()))

    D.sort()
    i = N//2

    if D[i] != D[i-1]:
        
        print(D[i]-D[i-1])
        return
    print(0)
    

if __name__ == "__main__":
    solve()

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

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())
d = list(map(int,input().split()))

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

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

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

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

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

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

Solution (Python):




def count_choices(n, nums):
    if n & 1 == 1:
        return 0

    nums.sort()

    mid = n // 2

    if nums[mid] == nums[mid - 1]:
        return 0

    return nums[mid] - nums[mid - 1]


def main():
    n = int(input())
    nums = list(map(int, input().split()))

    ans = count_choices(n, nums)
    print(ans)


main()

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

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

print(b-a)

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

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())
value = list(map(int,input().split()))
value.sort()
print(value[(int(N/2))]-value[(int(N/2))-1])

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

ans = p[int(n/2)] - p[int(n/2)-1]
print(ans)