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

abc = d[n//2 - 1]
agc = d[n//2]

if agc == abc:
    print(0)
else:
    print(agc-abc)

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

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

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 = list(map(int,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()
print(D[n//2] - D[n//2-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())))

while len(d) != (N/2)+1:
    d.pop()

ans = 0
for i in range(d[-2], d[-1]):
    ans += 1
print(ans)

Solution (Python):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

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

i = int(N / 2)
print(L[i] - (L[i - 1]))

Solution (Python):
n=int(input())
d=[int(i) for i in input().split()]
d=sorted(d)
if n%2==0:
    dmi=d[n//2-1]
    dma=d[n//2]
    ans=dma-dmi
else:
    ans=0
    
print(ans)

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

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

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

halfN = N // 2
D.sort()


count = 0

left = D[halfN - 1]
right = D[halfN]



ans = right - left

print(ans)

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

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

if mr - ml < 1:
	print(0)
elif mr- ml ==1:
	print(1)
else:
	print(mr - ml)

Solution (Python):
import sys
from collections import Counter


n = int(input())
c = Counter(map(int, input().split()))
c = sorted(c.most_common(len(c)), key=lambda a: a[0])
total_cnt = 0
for i, (a, b) in enumerate(c):
    total_cnt += b
    if total_cnt == n // 2:
        print(c[i + 1][0] - c[i][0])
        sys.exit()
print(0)

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())
nums = sorted(map(int, input().split()))
low = nums[(n - 1) // 2]
high = nums[(n - 1) // 2 + 1]
print(high - low)

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

d.sort()

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

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

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

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

min_d=d[int(N/2-1)]
max_d=d[(int(N/2))]
ans = max_d - min_d
if ans == -1:
    ans = 0
print(ans)

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

import statistics as st
import math

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

d.sort()


mid = int(len(d)/2)

kmax = d[mid]
kmin = d[mid-1]

print(kmax - kmin)

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

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

Solution (Python):
import math
import copy




def getInputNum():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList



a = getInputNum()
b = getInputListInt()

c = sorted(b)

mean = c[int(a/2)-1]
next = c[int(a/2 + 1)-1]

ans = next - mean

print(ans)

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

l = int(-(-(n//2)))

print(int(d[l] - d[l-1]))

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

d.sort()

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

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())
lst = list(map(int, input().split()))
mid = int(N/2 - 1)
lst = sorted(lst)
if lst[mid] == lst[mid+1]:
    print(0)
elif lst[mid] < lst[mid+1]:
    print(lst[mid+1]-lst[mid])

Solution (Python):
import sys

indata = sys.stdin.read().strip().splitlines()[1]
numbers = sorted(map(int, indata.split(" ")))
if len(numbers) % 2 != 0:
  print(0)
  sys.exit(0)

center = len(numbers) // 2
v1, v2 = numbers[center - 1], numbers[center]
if v1 == v2:
  print(0)
  sys.exit(0)
print(v2 - v1)

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

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

len = int(len(d))

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

Solution (Python):
N = int(input())
D = sorted([int(d) for d in input().split()])
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 = list(map(int,input().split()))

d.sort()

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

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

m = d[n // 2 - 1]
n = d[n // 2]

if m == n:
    print(0)
else:
    print(n - m)

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

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

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

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

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

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

Solution (Python):



import math

N = int(input())

inputV = input("")
arrayV = [int(n) for n in inputV.split()]
arrayV.sort()

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

print(ans)

Solution (Python):
import bisect

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

list_d_sorted = sorted(list_d)
jugde_num = N/2

cnt =0

for i in range(1,max(list_d)+1):
    index = bisect.bisect_left(list_d_sorted,i,)
    if index ==jugde_num:
        cnt +=1
print(cnt)

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

d.sort()

ABCmax = d[N // 2 - 1]
ARCmin = d[N // 2]

print(ARCmin - ABCmax)

Solution (Python):
from collections import Counter

N = int(input())
d = [int(i) for i in input().split()]
d_dic = Counter(d)
count = 0
dp = 0
for i in range(1,max(d)+1):
    dp += d_dic[i]
    if dp == N / 2:
        count += 1
    elif dp > N / 2:
        break
print(count)

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

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

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

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

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

if dis ==0:
    print(0)
else:
    print(dis)

Solution (Python):
n=int(input())
readints = lambda: map(int,input().split(' '))
a=list(readints())
a.sort()
mid = n//2
x=a[mid-1]
y=a[mid]
print(y-x)

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

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

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

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

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

sorted_D = sorted(D)

print(len((range(sorted_D[N//2-1]+1, sorted_D[N//2]+1))))

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

d.sort()

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

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

Solution (Python):

import numpy as np

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



if n % 2 == 1:
    print(0)
else:
    i = n // 2
    border1 = d[i]
    border2 = d[i- 1]
    if (border1 - border2) == 0:
        print(0)
    else:
        print(border1 - border2)

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

Solution (Python):
def getlist():
    return list(map(int, input().split()))

N = int(input())
d = getlist()
d = sorted(d)
m = int(N // 2)

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

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

if __name__ == '__main__':
    print(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[(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())
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()
n = N//2
print(d[n]-d[n-1])

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

t = int(n/2)
D.sort()

ans = D[t]-D[t-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())
D = list(map(int, input().split(' ')))
D.sort()


half_D = int(N / 2)

"""場合分け
1.中間で区切った小さい方と大きい方の数字が異なる
OK
2.同じ数字
NG
"""


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

else:
  print(D[half_D] - D[half_D-1])

Solution (Python):
import sys
N = int(sys.stdin.readline())
dlist = [int(d) for d in sys.stdin.readline().split()]

sorted_dlist = sorted(dlist)
half_i = int(N//2)
print(sorted_dlist[half_i]-sorted_dlist[half_i-1])

Solution (Python):
import sys

input = sys.stdin.readline

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

Solution (Python):
import sys

input = sys.stdin.readline

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

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

Ds = list(sorted(D))
p = int(len(D) / 2)
DsL = Ds[p - 1]
DsR = Ds[p]
Ks = DsL + 1
Ke = DsR

print(Ke - Ks + 1)

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

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

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

D=sorted(D)
sum=[]
count=0
for i in reversed(range(len(D))):
    sum.append(D.pop(i))
    if len(sum) == len(D):
        Ans=len(sum)
        break
for i in range(D[Ans-1],sum[Ans-1],1):
    count+=1
print(count)

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

Solution (Python):

N=int(input())
d=list(map(int,input().split())) 
ans=0
d.sort()
umed=int((N-1)/2)
omed=int((N+1)/2)
ans=d[omed]-d[umed]  

print(ans)

Solution (Python):
n = int(input())
d_list = list(map(int, input().split()))
sorted_d_list = sorted(d_list)
half_n = n // 2

if sorted_d_list[half_n-1] == sorted_d_list[half_n]:
    print(0)
else:
    print(sorted_d_list[half_n]-sorted_d_list[half_n-1])

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

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

max_abc = ds[int(n/2 - 1)]
min_arc = ds[int(n/2)]

print(min_arc - max_abc)

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

array.sort()

m = n//2

mae = array[m-1]
usiro = array[m]

print(usiro-mae)

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

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

Solution (Python):

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

d.sort()


center = len(d)//2

ans = d[center] - d[center-1]

print(ans)

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

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

Solution (Python):
def resolve():
    n = int(input())
    ds = map(int, input().split())

    sorted_ds = sorted(ds)
    mid_diff = sorted_ds[n // 2] - sorted_ds[n // 2 - 1]
    if mid_diff == 0:
        print(0)
    else:
        print(mid_diff)

resolve()

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

d.sort()
start = d[N/2-1]
end = d[N/2]

if start == end:
    print 0
else:
    print (end - start)

Solution (Python):

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


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

Solution (Python):

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


mid_left = len(D)//2 -1

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

Solution (Python):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



N = I()
d = III()

d.sort()
x1 = d[N//2-1]
x2 = d[N//2]

print(x2-x1)

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

num=0
ans=0
i=0
mid=len(d)/2
while num!=len(d):
    i+=1
    while d[num]<i:
        num+=1
        if(num==len(d)):
            break
    if(num==mid):
        ans+=1
print(ans)

Solution (Python):
if __name__ == '__main__':
	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() )
S=input().split(" ")

for i in range ( N ) :
    S[i] = int(S[i])

S.sort()

ini = S[int(N/2)-1]
fin = S[int(N/2)]

print ( fin - ini )

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(x) for x in input().split()])

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

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

c = [0] * N 
i = 0
tmp = d[0]
count = 1
 
for j in range(1,N):
    if tmp == d[j]:
        
        count += 1
    else:
        
        tmp = d[j]   
        c[i] = count
        count = 1
        i += 1

 
hantei = 0
hantei1 = 0

for j in range(N):
    hantei += c[j]
    if len(d) / 2 == hantei:
        hantei1 = 1
        break
    elif len(d) / 2 < hantei:
        
        break
 
if hantei1 == 1:
    print(d[len(d)//2] - d[len(d)//2-1])
else:
    print(0)

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

main()

Solution (Python):
from math import factorial, ceil, floor 
from operator import itemgetter as ig
from collections import defaultdict as dd

INF = float("inf")
MOD = int(1e9 + 7)

def main():
    N = int(input())
    D = tuple(map(int, input().split()))

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

main()

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()
d = [int(i) for i in input().split()]
if len(d) % 2 == 1:
  ans = 0
else:
  d.sort()
  if d[len(d)//2-1] == d[len(d)//2]:
    ans = 0
  else:
    ans = d[len(d)//2] - d[len(d)//2-1]
    
print(ans)

Solution (Python):
n=int(input())
half=n//2
numlist=[int(i) for i in input().split()]

numlist.sort()
a=numlist[half-1]
b=numlist[half]
print(b-a)

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

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

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

sorted_d = sorted(d)
h = n // 2
mid_left = sorted_d[h-1]
mid_right = sorted_d[h]

if mid_left == mid_right:
    print(0)
else:
    print(mid_right - mid_left)

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())
p=sorted(list(map(int, input().split())))
print(p[int(n/2)]-p[int(n/2)-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()
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()
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()
a = d[N//2-1]
b = d[N//2]
print(b-a)

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

D = sorted(D, reverse=False)

if N%2 == 0:
    ans = D[N // 2] - D[N // 2 - 1]
else:
    ans = 1

print(ans)

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

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

d = sorted(d)

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

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

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

H = sorted(H)

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

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

Solution (Python):
N = int(input())
s = sorted(list(map(int, input().split())))
out = 0

d = {}
for x in s:
    if x in d:
        d[x] += 1
    else:
        d[x] = 1

s = sorted(list(set(s)))
count = 0
l = 0
for x in s:
    if l != 0:
        out += x-l
        break
    else:
        count += d[x]
        if count == N/2:
            l = x
print(out)

Solution (Python):
def main():
    _ = int(input())
    ds = list(map(int, input().split()))
    ds = sorted(ds)
    midpoint = len(ds) // 2
    if ds[midpoint] == ds[midpoint - 1]:
        score = 0
    else:
        score = ds[midpoint] - ds[midpoint - 1]

    print(score)


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

import sys


def solve(N: int, d: "List[int]"):
    d = sorted(d)
    low = d[N//2 - 1]
    high = d[N//2]
    print(high - low)
    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())
D = sorted(list(map(int, input().split())))
l, r = D[N//2-1], D[N//2]
print(r-l)

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

center = n // 2

if(arr[center] == arr[center-1]):
    result = 0
else:
    result = arr[center] - arr[center-1]

print(result)

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

Solution (Python):
import statistics
import math

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

s_d=sorted(d)

median = s_d[n//2-1]

print(s_d[n//2]-median)

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

m = N // 2
a, b = d[m], d[m-1]

print(a- b)

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

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

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

d = sorted(d)

lower = d[N//2 -1]
upper = d[N//2]

print(len(range(lower, upper)))

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

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

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

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

h = N//2

d_sorted = sorted(d_ls)
h_low = d_sorted[h-1]
h_high = d_sorted[h]


print(h_high - h_low)

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

Ds.sort()
mid = int(N / 2)
if Ds[mid] == Ds[mid-1]:
    print(0)
else:
    print(Ds[mid] - Ds[mid -1])

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

Solution (Python):
def solve():
    n = int(input())
    ds = sorted(list(map(int, input().split())))
    abc_max = ds[n // 2 - 1]
    arc_min = ds[n // 2]
    return arc_min - abc_max


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

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

d.sort()
h = n // 2

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

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

l = sorted(d)
abc = l[:n//2][-1]
arc = l[n//2:][0]

print(arc-abc)

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

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

Solution (Python):
from statistics import*
input()
d=list(map(int,input().split()))
print(median_high(d)-median_low(d))

Solution (Python):
N = int(input())
D = sorted(list(map(int, input().split())))
check = []
half = int(len(D)/2)
D_lead = D[:half]
D_tail = D[half:]
if max(D_lead) != min(D_tail):
    check = [num for num in range(max(D_lead), min(D_tail))]
    print(len(check))
else:
    print(0)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
B = sorted(A)
print(B[N//2]-B[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] + 1) + 1, 0))

Solution (Python):
def main():
    n = int(input())
    ds = list(map(int, input().split()))
    cs = [0] * 100001
    for d in ds:
        cs[d] += 1
    abc = 0
    res = 0
    for k in range(2, 100001):
        abc += cs[k - 1]
        if abc * 2 == n:
            res += 1
        elif abc * 2 > n:
            break
    print(res)


if __name__ == "__main__":
    main()

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

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

Solution (Python):
def main():
  n = int(input())
  ds = list(map(int, input().split(' ')))
  ans = 0
  if n % 2 == 1:
    pass
  else:
    s = sorted(ds)
    l, r = s[n//2-1], s[n//2]
    if l == r:
      pass
    else:
      ans = r - l
  print(ans)


if __name__ == '__main__':
  main()

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):
N=int(input())
d_list=[int(x) for x in input().split()]
if len(d_list)%2>0:
    print(0)
else:
    d_sort=sorted(d_list)
    half=int(len(d_list)/2)
    print(d_sort[half]-d_sort[half-1])

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

f=d[:len(d)//2]
l=d[len(d)//2:]

diff=l[0]-f[-1]

print(diff)

Solution (Python):
import sys

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

if len(d) % 2 == 1:
    print(0)
    sys.exit()

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

Solution (Python):

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

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

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

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

if N % 2 == 1:
  print (0)
else:
  d.sort()

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

Solution (Python):
def divide_problems(n,d):
    ans = 0
    _d = sorted(d)
    ans = _d[n/2] - _d[n/2-1]
    return ans

if __name__ == '__main__':
    n = int(raw_input())
    d = list(map(int,raw_input().split()))

    print divide_problems(n,d)

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

a.sort()
mid=int(len(a)/2)
print(a[mid]-a[mid-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()))

sd = sorted(d)

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

else:

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

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

D = sorted([int(v) for v in input().split()])
arc = N // 2
abc = arc - 1
print(D[arc] - D[abc])

Solution (Python):
n = int(input())
d = sorted(list(map(int, input().split())))
l = []
r = []
for elm in d:
  if len(l) < n / 2 or l[-1] == elm:
    l.append(elm)
  else:
    r.append(elm)

if len(l) != len(r):
  print(0)
else:
  ans = r[0] - l[-1]
  print(ans)

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

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

D.sort()

s=D[(N//2)-1]
b=D[(N//2)]


K=b-s
print(K)

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

length = len(d)
length_half = int(length/2)


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

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