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.sort()
print(D[N//2] - D[N//2-1])

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

d.sort()

left = int((len(d)/2)-1)
right = int(len(d)/2)

cnt = 0
for i in range(d[left]+1,d[right]+1):
    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()))
n = int(N/2)
sortd = sorted(d)
a = sortd[n-1]
b = sortd[n]
print(b-a)

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

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

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

	
	
	

	c = List[int(len(List)/2)]
	cm = List[int(len(List)/2) -1]
	

	print(c-cm)

if __name__ == "__main__":
	main()

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()
A.sort()
print(A[N//2] - (A[N//2-1]))

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

c=len(d)//2
ans=0
for i in range(d[c-1]+1,d[c]+1):
      if n//2==bisect.bisect_left(d,i):
            ans+=1
print(ans)

Solution (Python):
n = int(input())
*d, = sorted(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 d[N//2] == d[(N//2)-1]:
    print(0)
else:
    print(d[N//2] - d[(N//2)-1])

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

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

arr = sorted(arr0)

a0 = arr[num//2]
a1 = arr[num//2 -1]

if a0 == a1:
    print(0)

else:
    print(a0-a1)

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()
i = n // 2
i_1 = i - 1
if d[i] == d[i_1]:
    print(0)
else:
    print(d[i] - d[i_1])

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

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

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


if n % 2 != 0:
  print('No')
else:
  b = n//2
  print(max(0,a[b]-a[b-1]))

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

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

abc = d_list[int(N/2)-1]
arc = d_list[int(N/2)]

print(arc-abc)

Solution (Python):

import math
import heapq
import bisect

MOD = 10**9+7

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

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

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

Solution (Python):


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

ds.sort()
middle = int(len(ds)/2)
minimum = ds[middle-1]
maximumm = ds[middle]

print(maximumm-minimum)

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

d.sort()

d_max = d[len(d)//2:]
d_min = d[:len(d)//2]

ans = d_max[0] - d_min[-1]
print(ans)

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N=II()
lis=LI()
lis.sort()
if lis[N//2-1] != lis[N//2]:
    print(lis[N//2] - lis[N//2-1])
else:
    print(0)

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

if Min==Max:
  ret = 0
else:
  ret = Max - Min

print(ret)

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(raw_input())
D = map(int, raw_input().split())

D_sort = D.sort()

L_value = D[N/2-1]
R_value = D[N/2]

print R_value - L_value

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

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

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

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

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

n = ii()
d = li()

d_sort = sorted(d)
d_abc = d_sort[:n//2]
d_arc = d_sort[n//2:]

if d_abc[-1]==d_arc[0]:
    print(0)
else:
    print(d_arc[0]-d_abc[-1])

Solution (Python):
import sys

n = int(sys.stdin.readline())
d = list(map(int, sys.stdin.readline().split()))

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

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

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

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

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

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

Solution (Python):
n = int(input())
d = [num for num in map(int, input().split(' '))]
sorted_d = sorted(d)

half_i = n // 2
ans = sorted_d[half_i] - sorted_d[half_i-1]

print(ans)

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

s = sorted(d)
print(s[len(d)//2] - s[len(d)//2-1])

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

print(y-x+1)

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

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

Solution (Python):
import bisect

N = int(input())
d = list(map(int, input().split()))
D_MAX = max(d)
d_sort = sorted(d)

k_min = 10 ** 6
k_max = -1
center = N // 2
count = 0
for i in range(1, D_MAX + 1):
    if bisect.bisect_left(d_sort, i) == center:
        count += 1
print(count)

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
def print_ans(n,dr):
    """Test Case
    >>> print_ans(6, [9, 1, 4, 4, 6, 7])
    2
    >>> print_ans(8, [9, 1, 14, 5, 5, 4, 4, 14])
    0

    >>> print_ans(14, [99592, 10342, 29105, 78532, 83018, 11639, 92015, 77204, 30914, 21912, 34519, 80835, 100000, 1])
    42685
    """
    ans_ar = sorted(dr)
    print(ans_ar[n//2] - ans_ar[n//2 - 1])

if __name__ == '__main__':
    n = int(input().rstrip())
    dr = list(map(int, input().rstrip().split()))
    print_ans(n,dr)

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

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


def main():
    sc = Scan()
    n = sc.intarr()[0]
    d = sc.intarr()
    d.sort()
    print(d[n//2] - d[n//2 - 1])


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()

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


def main():
    sc = Scan()
    n = sc.intarr()[0]
    d = sc.intarr()
    d.sort()
    ans = d[n//2] - d[n//2 - 1]
    print(ans)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()

Solution (Python):
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0
n = inp()
d = inpl()

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

Solution (Python):

import sys










def main():
    n, *difficulties = [int(x) for x in sys.stdin.read().split()]
    difficulties.sort()

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

if __name__ == "__main__":
    main()

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

li.sort()

max_val = li[n // 2]
min_val = li[n // 2 - 1]

print(max_val - min_val)

Solution (Python):
N = int(input())
D = sorted([int(x) for x in input().split()])
l = D[len(D)//2-1]
h = D[len(D)//2]
if l == h:
  print(0)
else:
  print(h - l)

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

l = 0

if N != 0:
    d.sort()
    l = len(list(range(d[N // 2 - 1] + 1, d[N // 2] + 1)))

print(l)

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

d_sort = list(sorted(d))
d_1 = d_sort[:N//2]
d_2 = d_sort[N//2:]
print(d_2[0] - d_1[-1])

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

l = D[N//2-1]
r = D[N//2]

print(r-l)

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

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

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

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

Solution (Python):

import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    ds = [int(x) for x in input().split()]

    ds.sort()

    n = N//2 - 1
    if ds[n] >= ds[n+1]:
        print(0)
        return
    print(ds[n+1]-ds[n])



if __name__ == '__main__':
    main()

Solution (Python):
def solve():
    N, *d_l = map(int, open(0).read().split())
    d_l.sort()

    if d_l[N//2] == d_l[N//2-1]:
        print(0)
    else:
        print(d_l[N//2] - d_l[N//2-1])



if __name__ == '__main__':
    solve()

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

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

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

dn.sort()

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

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

print(cnt)

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

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


def main():
    N = int(input())
    d = list(map(int, input().split()))
    D = []

    for (k, v) in enumerate(d):
        D.append((v, k))

    D = sorted(D)
    a = D[len(D)//2-1]
    b = D[len(D)//2]
    diff = b[0] - a[0]
    
    print(diff)


if __name__ == '__main__':
    main()

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

k = d_list[int(N/2)]
count = 0
for i in range(N):
    if count == int(N/2):
        print(d_list[int(N/2)] - d_list[int(N/2)-1])
        break
    elif k > d_list[i]:
        count += 1
    else:
        pass
else: 
    print(0)

Solution (Python):
n = int(input())
d = list(map(int, input().split()))
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):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    if(n%2):
        print(0)
        return
    A.sort()
    print(A[n//2]-A[n//2-1])
resolve()

Solution (Python):



n = int(input())

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

dl = sorted(dl)

min_d = dl[n//2-1]
max_d = dl[n//2]
print(max_d-min_d)

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

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

Solution (Python):
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([9, 1, 4, 4, 6, 7]), 2)

    def test_2(self):
        self.assertEqual(think([9, 1, 14, 5, 5, 4, 4, 14]), 0)

    def test_3(self):
        self.assertEqual(think([99592 ,10342 ,29105 ,78532 ,83018 ,11639 ,92015 ,77204 ,30914 ,21912 ,34519 ,80835 ,100000 ,1]), 42685)


def solve():
    d = read()
    result = think(d)
    write(result)


def read():
    n = read_int(1)[0]
    return read_int(n)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    n = len(data)
    data.sort()
    right_index = n // 2
    left_index = n // 2 - 1
    return data[right_index] - data[left_index]


def write(result):
    print(result)


if __name__ == '__main__':
    
    solve()

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

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

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 = list( map(int, input().split() ) )
d_list.sort()
divide = int( N/2 )
if d_list[divide] == d_list[divide - 1]:
    print(0)
else:
    print( d_list[divide] - d_list[divide - 1] )

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

L.sort()

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

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

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

print(int(after_median - before_median))

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

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

ind = 0
small = 0

if(n%2 != 0):
    print(0)
else:
    ind = int(n/2)
    d1 = d[ind-1]
    d2 = d[ind]
    
    if(d1 == d2):
        print(0)
    else:
        print(d2-d1)

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

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

l = len(d)//2
print(0 if d[l-1] == d[l] else d[l]-d[l-1])

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

ans = d[n//2] - d[(n-1)//2] 

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

Solution (Python):
import statistics
N = int(input())
d = list(map(int,input().split()))
d_low = statistics.median_low(d)
d_high = statistics.median_high(d)
ans = d_high - d_low
print(ans)

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

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

d.sort()
count = 0

if n % 2 == 1:
    print("0")
    exit(0)
else:
    if d[int(n/2)-1] == d[int(n/2)]:
        print("0")
        exit(0)
    else:
        k = d[int(n/2)-1]
        while(1):
            if k != d[int(n/2)]:
                count += 1
                k = k + 1
            else:
                break

print(count)

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

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

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

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

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

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





max = Ds[(len(Ds) // 2)]
min = Ds[(len(Ds) // 2) - 1] 

print(max - min)

Solution (Python):

n = int(input())
dl = list(map(int, input().split()))
dl = sorted(dl)

if n%2==0:
    x = dl[n//2-1]
    y = dl[n//2]
    print(y-x)
else:
    print(0)

Solution (Python):
N=int(input())
D=list(map(int,input().split()))
D.sort()
mi=D[0]
ma=D[N-1]
point=0
for j in range(mi,ma+1): 
    if D[N//2-1]<j<=D[N//2]:
        point+=1
print(point)

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

sort_D=sorted(D)

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

print(ans)

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

sorted_d = sorted(d)

mid = int(n / 2)

mid_ceil = sorted_d[mid]
mid_floor = sorted_d[mid - 1]

ans = mid_ceil - mid_floor

print(ans)

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

'''
r = 0
b = 0
cnt = 0

while k in range(n):
    for k in range(k):
        if d[k] >= k+1:
            r += 1
        else:
            b += 1

if r == b:
     cnt += 1
print(cnt)
'''

sortedd = sorted(d)
ans = 0
if not sortedd[n//2-1] == sortedd[n//2]:
    ans += sortedd[n//2] - sortedd[n//2-1]
print(ans)

Solution (Python):
def main():
    N = int(input())
    D = list(map(int,input().split()))
    D_sorted = sorted(D)
    if D_sorted[int(N/2-1)] == D_sorted[int(N/2)]:
        print(0)
        return
    print(D_sorted[int(N/2)]-D_sorted[int(N/2-1)])


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = sorted([int(i) for i in input().split()])
ans = 0
if n % 2 == 0:
    if not a[n // 2 - 1] == a[n // 2]:
        ans += a[n // 2] - a[n // 2 - 1]

print(ans)

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

if d[int(n/2)]!=d[int((n/2)-1)]:
  for i in d:
    if i==d[int(n/2)]:
      gn+=1
  if gn>=1:
    a+=1
  print(a)
     
else:
  print(0)

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

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

num = sorted(d)
length = len(num)
if length % 2 == 1:
  print(0)
  exit(0)
else:
  ans = num[int(length/2)] - num[int((length/2) - 1)]
  print(ans)

Solution (Python):

"""
C - Divide the Problems
https://atcoder.jp/contests/abc132/tasks/abc132_c

"""
import sys
from bisect import bisect_left, bisect_right

def solve(n, problems):
    lb, ub = 0, n
    while ub - lb > 1:
        mid = (lb + ub) // 2
        i = bisect_left(problems, problems[mid])
        if i < n // 2:
            lb = mid
        else:
            ub = mid
    return problems[ub] - problems[lb] if lb + 1 == n // 2 else 0


def main(args):
    n = int(input())
    problems = sorted([int(x) for x in  input().split()])
    ans = solve(n, problems)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

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

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

Solution (Python):
n = int(input())
D = list(map(int,input().split()))
nc = n//2
D.sort()
print(D[nc] - D[nc-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 = [int(x) for x in input().split()]

d.sort()

if d[N//2-1]-d[N//2] == 0:
  print(0)
else:
  print(-d[N//2-1]+d[N//2])

Solution (Python):
import heapq

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

heapq.heapify(d_list)

target_idx = n // 2 - 1
for _ in range(0, target_idx):
    heapq.heappop(d_list)

base_value1 = heapq.heappop(d_list)
base_value2 = heapq.heappop(d_list)

print(base_value2 - base_value1)

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

d.sort()
ans = len(range(d[N//2 - 1] + 1, d[N//2]+1))
print(ans)

Solution (Python):
S = int(input())
A = sorted(map(int, input().split()))  
m = len(A) // 2

print(len(list(range(A[m-1], A[m]))))

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

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

l = D[n//2 - 1]
u = D[n//2]

print(u - l)

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

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

Solution (Python):
from heapq import *

N=int(input())
d=list(map(int,input().split()))
h=[]
for i in d:
    heappush(h,i)
for i in range(N//2-1):
    heappop(h)
a=heappop(h)
b=heappop(h)
print(b-a if b!=a else 0)

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

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

d.sort()
m = int(n / 2)
i = d[m-2] + 1
if (d[m-1] != d[m]):
  print(d[m] - d[m-1])

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

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

arr = sorted(arr_in)

n = int(n/2)

res =  arr[n] - arr[n-1]
print(res)

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

arr = sorted(arr_input)
i = int(n/2)

ans = arr[i] - arr[i-1]

if ans == 0:
    print(0)
else:
    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):
def solve():
    n = int(input())
    d = sorted(map(int, input().split()))
    return d[n//2] - d[n//2-1]

if __name__ == '__main__':
    print(solve())

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

abc = d[:N//2]
arc = d[N//2:]
print(arc[0] - abc[-1])

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

if N % 2 == 1:
    print(0)
else:
    d.sort()
    d1 = d[N // 2 - 1]
    d2 = d[N // 2]
    print(d2 - d1)

Solution (Python):
n = int(input())
d = input().split()
t = []

for i in range(n):
    t.append(int(d[i]))

t.sort()

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

print(ans)

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

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

a=d[:N//2]
b=d[N//2:]
a.sort(reverse=False)
b.sort(reverse=False)

print(b[0]-a[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 = list(map(int, input().split()))

D = sorted(D)
n = int(N/2)

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

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

sortD = sorted(D)
print(sortD[int(N/2)] - sortD[int(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())
a=list(map(int,input().split()))
a.sort()
med_1=a[n//2-1]
med_2=a[n//2]

print(med_2-med_1)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,*D = map(int,read().split())

n = N//2
D.sort()
answer = D[n] - D[n-1]
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=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):



def main():

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






if __name__ == "__main__":
    main()

Solution (Python):



def main():

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






if __name__ == "__main__":
    main()

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

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()
i = n//2
a = d[i-1]
b = d[i]
ans = 0
for j in range(a+1,b+1):
  ans+=1
print(ans)

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