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

Solution (Python):
import statistics


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

    med_low = statistics.median_low(d_list)
    med_high = statistics.median_high(d_list)

    if med_high == med_low:
        answer = 0
    else:
        answer = med_high - med_low

    print(answer)

Solution (Python):
import numpy as np

N = int(input())
difficulty = np.sort(np.array([int(num) for num in input().split(" ")]))

num_K = difficulty[N/2] - difficulty[((N/2)-1)]
print(num_K)

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

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

if n%2==1:
    print("0")
else:
    m=n//2
    s=sorted(d)
    ans=s[m]-s[m-1]
    print(ans)

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

dx=sorted(d)

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

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

Solution (Python):
import bisect

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

d.sort()

for i in range(100001):
    if(bisect.bisect_left(d, i)==N/2):
        ans +=1


print(ans)

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

K = 0

d.sort()

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

print (sum)

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

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

Solution (Python):


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

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

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

dic = {}

for e in d :
    if e not in dic :
        dic[e] = 1
    else :
        dic[e] += 1

dic = sorted(dic.items(), key=lambda x:x[0])



sum = 0
ancker = 0
tmp = 0
ans = True

for i in range(len(dic)):
    sum += dic[i][1]
    if sum == N / 2 :
        ancker = i
        break;
    if sum > N / 2 :
        ans = False
        break


if not ans :
    print(0)
else :
    print(dic[ancker+1][0] - dic[ancker][0])

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

d.sort()

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

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

DS = sorted(D)
A = DS[N//2-1]
B = DS[N//2]
AB = B - A

print(AB)

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

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

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

Solution (Python):
N = int(input())
d = sorted(list(map(int, input().split(' '))))
ret = 0
l = d[N//2 - 1]
r = d[N//2]
if l < r:
    ret = r - l   
print(ret)

Solution (Python):
n = int(input());
d = input().split(" ");
for i in range(n) :
	d[i] = int(d[i]);
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):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
logging.disable(logging.CRITICAL)

K = int(input())
L = list(int(x) for x in input().split())

Ld = sorted(L)

if Ld[int(K / 2) - 1] == Ld[int(K / 2)]:
    print(0)
else:
    print(Ld[int(K / 2)] - Ld[int(K / 2) - 1])

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

d.sort()

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

print( count )

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



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

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

sd = sorted(d)
low = sd[N//2-1]
up = sd[N//2]
num = up - low
print(num)

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

left = d[mid-1]
right = d[mid]

ans = 0

l = 0
for i in d:
    if i >= right:
        l += 1

if l == mid:
    ans += 1

if right != left:
    ans += right - left - 1 

print(ans)

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

def judge(D):  
    D.sort()
    half = int(N/2)
    
    if (N%2)==1:
        return 0
    if D[half]==D[half-1]:
        return 0
    ans = D[half]-D[half-1]
    return ans

print (judge(D))

Solution (Python):



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


ans = 0
d = sorted(d)
center = int(N / 2)
if d[center - 1] != d[center]:
    for i in range(d[center] - d[center - 1]):
        ans += 1


print(ans)

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

dl.sort()
half = int(n / 2)
diff = dl[half] - dl[half - 1]
if diff == 0:
    print(0)
else:
    print(diff)

Solution (Python):


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

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

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

Solution (Python):
import numpy as np
n = int(input())
li = list(map(int,input().split()))
li.sort()
arr_li = np.array(li)
if(arr_li[int(n/2)] == arr_li[int(n/2-1)]):
    print('0')
else:
    print(arr_li[int(n/2)]-arr_li[int(n/2-1)])

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

e=[0 for i in range(100000)]

for i in range(N):
	e[d[i]-1]=e[d[i]-1]+1

k = 0
c = 0
for i in range(100000):
	k = k + e[i]
	if k==int(N/2):
		c = c+1

print(c)

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

d = sorted([int(x) for x 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):

from math import factorial

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

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

Solution (Python):
import numpy as np

N = int(input())
arr = [int(i) for i in input().split()]
arr = np.sort(arr)
m1 = arr[int(N / 2)-1]
m2 = arr[int(N / 2)]
print(m2 - m1)

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

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

Solution (Python):
import collections

N = input()
score = input()

score = list(map(int,score.split(" ")))
sorted_num = sorted(score)

mid = int(len(sorted_num)/2)
mid_flont,mid_back = sorted_num[mid-1], sorted_num[mid]

mid_c = (mid_back - mid_flont)
if not mid_c > 0:
    print(0)
else:
    print(mid_c)

Solution (Python):

def code_for_C(test=None):

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

    list_d.sort()

    half_smaller = list_d[int(N/2)-1]
    half_larger = list_d[int(N/2)]

    print(half_larger - half_smaller)
    
code_for_C()

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

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

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

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

print(K)

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

Solution (Python):

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

d.sort()

if d[N//2 - 1] == d[N//2]:
    output = 0
else:
    output = d[N//2] - d[N//2-1]

print(str(output))

Solution (Python):
N=int(input())
permu=list(map(lambda x:int(x),input().split()))
permu=sorted(permu)
s,t=int(N/2)-1,int(N/2)
a=list(range(permu[s]+1,permu[t]+1))
print(len(a))

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


if len(D) & 2 == 1: ans = 0
else:


    D = sorted(D)

    a = D[int(len(D)/2) - 1]
    b = D[int(len(D)/2)]

    ans = b - a


print(ans)

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

d = sorted(d)

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

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

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

wari = n//2

if n%2==1:
    print(0)
    exit()

d.sort(reverse=True)

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

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

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

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

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

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

s.sort()


m = n//2 -1

ans = 0
if s[m+1] == s[m]:
    ans = 0
else:
    ans = s[m+1]-s[m]

print(ans)

Solution (Python):

from statistics import median_high, median_low


def main():
    n = int(input())
    D = sorted(map(int, input().rstrip().split()))
    h, l = median_high(D), median_low(D)
    print(h - l)


if __name__ == "__main__":
    main()

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

Solution (Python):
import re

N = int(input())
d = sorted([int(i) for i in re.split(" ", input())])

x = d[N // 2 - 1]
y = d[N // 2]

print(y - x)

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

def is_big(k):
    countA = 0
    countB = 0
    for i in range(n):
        if d[i] >= k:
            countA += 1
        else:
            countB += 1

    if countA >= countB:
        return True
    else:
        return False

def solve(k):
    countA = 0
    countB = 0
    for i in range(n):
        if d[i] >= k:
            countA += 1
        else:
            countB += 1

    if countA == countB:
        return True
    else:
        return False

l = 0
r = 100000
m = (l + r) // 2


while l <= r:
    if is_big(m):
        l = m + 1
        m = (l + r) // 2
    else:
        r = m - 1
        m = (l + r) // 2




if solve(m):

    d.sort()
    for i in range(n):
        if d[i] == m:
            print(d[i] - d[i-1])
            break

else:
    print(0)

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

ds = sorted(ds)
startI = int(N/2)-1
endI = startI+1
print(ds[endI]-ds[startI])

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

Solution (Python):
n = int(input())
xlist = [int(iz) for iz in input().split()]

half = int(n/2)
xlist.sort()

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



ans = b-a

print(ans)

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

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

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

Solution (Python):
from collections import Counter
n = int(input())
p = Counter(list(map(int, input().split())))
p = sorted((x, p[x]) for x in p)

cnt = 0

if n % 2 == 0:
    s = n // 2
    pre = None
    for x, y in p:
        if p is None:
            p = x
        if s == 0:
            cnt = x - pre
            break
        s -= y
        pre = x


print(cnt)

Solution (Python):

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

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

if __name__=="__main__":
    main()

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

print(saki - temae)

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())
num = int(n/2)
d_n = list(map(int, input().split()))
d_n.sort()

d_n_min_max = d_n[num-1]
d_n_max_min = d_n[num]

delta = d_n_max_min - d_n_min_max
print(delta)

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

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

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

L.sort()




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

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

Solution (Python):
input()
x = input()
nums = x.split()



for i in range(len(nums)):
  nums[i] = int(nums[i])

nums.sort()
  
h = int(len(nums)/2)

if nums[h] == nums[h-1]:
  print("0")
  exit()

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

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


res = 0

dX.sort()

if n % 2 == 0:
    res = dX[n//2] - dX[n//2-1]
print(res)

Solution (Python):

N = int(input())
inputData = input().split()
D = [int(x) for x in inputData]
D.sort()
if D[int((N/2 - 1))] == D[int((N/2))]:
    print("0")
    exit()
print(D[int((N/2))] - D[int((N/2 - 1))])

Solution (Python):
n = int(input())
lst = sorted(list(map(int, input().split())))
cnt = 0
if len(lst)%2 != 0:
  print(0)
else:
  print(lst[int(len(lst)/2)] - lst[int(len(lst)/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(int(_) for _ in input().split()) 

d.sort()

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

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

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

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

Solution (Python):


"""
Created on Sat Jun 29 20:55:57 2019

@author: YudNK
"""

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

D.sort()

l = D[0:int(N/2)]
r = D[int(N/2):]

print(r[0] - l[-1])

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

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

d.sort()

min_value = d[len(d) // 2 - 1]
max_value = d[len(d) // 2]

print(max_value - min_value)

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


if __name__ == "__main__":
    n = int(input())
    d_list = li()

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

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

Solution (Python):
def main():
    N = int(input())
    *D, = map(int, input().split())

    m = N // 2
    D = sorted(D)

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


main()

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

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

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

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

qnum = len(diff_l)
if(qnum%2!=0):
    print(0)
else:
    print(diff_l[int(qnum/2)]-diff_l[int(qnum/2-1)])

Solution (Python):
import numpy as np

N = int(input())
a = input().split(" ")
d = [int(i) for i in a]
d.sort()
a = d[int(N/2)-1]
b = d[int(N/2)]
print(b-a)

Solution (Python):
n=int(input())
d=sorted([int(i) for i in input().split()])
dif=[0]*d[-1]
ruiseki=[0]*d[-1]
for i in d:
    dif[i-1]+=1
for i in range(d[-1]):
    ruiseki[i]=ruiseki[i-1]+dif[i]
SUM=sum(dif)
ans=0
for i in range(n-1):
    S=ruiseki[d[i]-1]
    if S==SUM-S:
        ans+=d[i+1]-d[i]
print(ans)

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

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

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
h = readl()
h.sort()
left = h[n // 2 - 1]
right = h[n // 2]
print(right - left)

Solution (Python):

import sys
import collections
import bisect

def main():
	
	N = int(input())
	d = list(input().split(" "))
	d = [int(s) for s in d]
	d.sort()
	base = (len(d))//2
	
	ans = 0
	for k in range(d[0]-1, d[-1]+2):
		tmp = bisect.bisect_left(d,k)
		if tmp == base:
			ans+=1
	
	print(ans)	
	
	
if __name__ == "__main__":
	main()

Solution (Python):
N = int(raw_input())
S = map(int, raw_input().split(' '))

S.sort()

minn = S[N/2-1]
maxn = S[N/2]

print(max(0, maxn-minn))

Solution (Python):

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

L.sort()
med1 = len(L)//2 -1
med2 = len(L)//2
if L[med1] == L[med2]:
  print(0)
else:
  print(L[med2] - L[med1])

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

med_low = statistics.median_low(d_ls)
med_high = statistics.median_high(d_ls)
if med_low == med_high and d_ls.count(med_low)==1:
    ans = 1
else:
    ans = med_high - med_low
    
print(ans)

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

d.sort()

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

Solution (Python):
import numpy as np

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

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

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

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

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

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

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

res=0
if n % 2 == 0:
    m=int(n/2)
    
    if d[m-1] == d[m]:
        pass
    else:
        res = d[m] - d[m-1] 

else:
    pass
    
    
print(res)

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

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

n = int(N/2) - 1

a = d[n]
b = d[n + 1]

print(b - a)

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

tbl = [0] * (mx+1)
for i in ds:
    tbl[i] += 1

cnt = 0
res = 0
for i in range(max(ds)):
    cnt += tbl[i]
    if cnt == n//2:
        res += 1
    elif cnt > n//2:
        break

print(res)

Solution (Python):
n = int(input())
q = sorted(list(map(int,input().split())))
h = n//2 -1
x = 0
for i in range(q[h]+1,q[h+1]+1):
  if i > q[h] and i <= q[h+1]:
    x += 1
print(x)

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

L.sort()
H = int(N/2)
A = L[H] - L[H-1]
if A > 0:
    print(A)
else:
    print(0)

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

sort_D = sorted(D)
mid = int(n / 2)
max_easy = sort_D[mid - 1]
min_difc = sort_D[mid]
print(min_difc - max_easy)

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

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

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

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

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

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

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())
s=sorted(list(map(int,input().split())))
m=int(n/2)

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

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

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
sysinput = sys.stdin.readline

N = int(sysinput())
d = [x for x in map(int, sysinput().split())]

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

Solution (Python):
from statistics import mean, median,variance,stdev
from collections import  Counter
n =int(input())
D = sorted(list(map(int,input().split())))
med = int(median(D))
middle = D[n//2+1 if n%2==1 else n//2 ]
if med >=middle:
	print(0)
else:
	print(D[(n//2+1 if n%2==1 else n//2)]-D[(n//2+1 if n%2==1 else n//2)-1])

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

print(high - low)

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

d.sort()

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

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

Solution (Python):
"""


 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())


 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  


a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    n= int(sys.stdin.readline())
    d= list(map(int, sys.stdin.readline().split()))
    d.sort()
    h=int(n/2)
    dz=d[:h]
    dk=d[h:]
    dz_max=max(dz)
    dk_min=min(dk)
    c=0
    print(dk_min-dz_max)

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

a = nums[len(nums) // 2 - 1]
b = nums[len(nums) // 2]

aida = b - a
cnt = 0
for i in range(aida + 1):
    if a < a + i and a + i <= b:
        cnt += 1

print(cnt)

Solution (Python):


N = int(input().rstrip())
d_s = input().split(" ")

d = [int(s) for s in d_s]
d.sort()
print(d[int(N/2)]-d[int(N/2-1)])

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

msort = sorted(m)
div = n//2
print(msort[div] - msort[div-1])

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

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

print(arc-abc)

Solution (Python):

import sys
input = sys.stdin.readline

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

d = sorted(d)

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

print(ans)

Solution (Python):
import numpy as np

N = int(input())
D = input()
D =  D.split(' ')
D = [int(d) for d in D]
D_sort = np.sort(D)

k = int(N/2)
count = 0

low_d = D_sort[k-1]
hight_D = D_sort[k]
dis = hight_D - (low_d+1) + 1

print(dis)

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

d.sort()

l = (n//2) -1
r = (n//2)

print(d[r]-d[l])

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

Solution (Python):
s = int(input())
l = list(int(x) for x in input().split())
cnt = 0
l.sort()




if l[len(l)//2-1] == l[len(l)//2]:
  print(0)
  exit()
for i in range((l[len(l)//2-1]+1),l[len(l)//2]+1):
  cnt += 1
print(cnt)

Solution (Python):


''' 
------------------------
author : iiou16
------------------------
'''

def main():
    N = int(input())
    p_list = list(map(int, input().split()))

    p_list = sorted(p_list)
    f = p_list[int(N/2 - 1)]
    c = p_list[int(N/2)]

    print(c - f)

if __name__ == '__main__':
    main()

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

abc = D[:l]
arc = D[l:]

print(min(arc) - max(abc))

Solution (Python):


import sys

def solve(input_):
    input_.sort()
    min_ = input_[len(input_) // 2 - 1]
    max_ = input_[len(input_) // 2]
    return max_ - min_

def main():
    sys.stdin.readline()
    inputs = [int(s) for s in sys.stdin.readline().rstrip().split(" ")]
    print(solve(inputs))

main()

Solution (Python):
def solve():
    N = int(raw_input())
    d = [int(_) for _ in raw_input().split()]
    d.sort()
    mid = N // 2
    ret = d[mid] - d[mid-1]
    print ret

if __name__ == '__main__':
    solve()

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

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

d.sort()

low,high = [d[(n//2)-1],d[n//2]]
print(high- low)

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

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

sd = sorted(d)

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

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

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

if d[center - 1] != d[center]:
    ans = d[center] - d[center - 1]
else:
    ans = 0

print(ans)

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

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

lst.sort()
middle = int(len(lst) / 2)

if(lst[middle] == lst[middle-1]):
  print(0)
else:
  print(lst[middle] - lst[middle-1])

Solution (Python):
import fractions
from collections import deque
import numbers as np


def main():
    N = int(input())
    d = list(map(int, input().split()))
    d.sort()
    bi_m = d[(N-1)//2]
    bi_p = d[(N-1)//2 + 1]
    print(bi_p - bi_m)


if __name__ == "__main__":
    main()

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

Solution (Python):


import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    d = i2nn()
    d.sort()
    before_half = d[int(N / 2 - 1)]
    after_half = d[int(N / 2)]
    print(after_half - before_half)
    return

main()

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    d = [int(i) for i in input().split()]
    d.sort()

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


if __name__ == "__main__":
    main()

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

d.sort()

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

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

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

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

Solution (Python):


n=int(input())
d=input().split(" ")
for i in range(n):
    d[i]=int(d[i])

d=sorted(d)
center=d[int(n/2)]

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

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

m = n//2
d = sorted(d)

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

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

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

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

dat.sort()

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

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

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

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