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

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

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

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

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

Solution (Python):
import bisect

n = int(input())
d = list(int(x) for x in input().split())
d.sort()

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

"""
for k in range(d[n // 2], d[(n // 2) + 1]):
    if bisect.bisect_left(d, k) == n // 2:
        ans += 1
"""

Solution (Python):
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    
    
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right
n=int(input())
S=list(map(int,input().split()))
S=quick_sort(S)
word=n//int(2)
s=int(S[word])-int(S[word-1])
s2=int(S[word])-int(S[word-1])
print(s)

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

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

D.sort()

result = D[N//2] - D[N//2-1]

print(result)

Solution (Python):
import numpy as np

size=input()
pro=input()

p=np.array(pro.split(" "),dtype=np.int32)
p=np.sort(p)

me=int(len(p)/2)

print(p[me]-p[me-1])

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

half = int((N / 2) -1)

K_under =  d[half]
K_over = d[half + 1]

K_num = K_over - K_under
print(K_num)

Solution (Python):
def c_divide_the_problems(N, D):
    D.sort()
    abc_max, arc_min = D[N // 2 - 1], D[N // 2]  
    return arc_min - abc_max if arc_min > abc_max else 0

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

Solution (Python):

import sys


def solve(N: int, d: "List[int]"):
    n = N // 2
    d = sorted(d)
    print(d[n] - d[n-1] )
    return



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

if __name__ == '__main__':
    main()

Solution (Python):
import heapq

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

q = []
for x in s:
  heapq.heappush(q, x)

for i in range(n//2):
  abc_max = heapq.heappop(q)
arc_min = heapq.heappop(q)
print(arc_min - abc_max)

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

Solution (Python):
n = input()
_difs = input().split(' ')
difs = [int(item) for item in _difs]
difs.sort()
pos=int(float((len(difs)+1))/float(2))
m = difs[pos]
print(difs[pos] - difs[pos-1])

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

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

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

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

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

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

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

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

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

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

Solution (Python):
from sys import stdin


def main():
    N = int(input())

    d = [int(x) for x in stdin.readline().split()]

    d.sort()

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



if __name__ == "__main__":
    main()

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):
x = int(input())
y = input().split()
for u in range(len(y)):
    y[u] = int(y[u])
y = sorted(y)
count = y[int(len(y) / 2)] - y[int((len(y) / 2)) - 1]
print(count)

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

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(int(i) for i in input().split()) 
n = N//2
data = sorted(L)
data1 = data[:n]
data2 = data[n:]
print(min(data2) - max(data1))

Solution (Python):
n = int(input())
P = map(int,input().split())
p = [i for i in P]
p.sort()
if n % 2 == 1:
    print(0)
elif len(p) == 2:
    if p[0]==p[1]:
        print(0)
    else:
        p.sort()
        print(p[1]-p[0])
else:
    if p[(n//2)] == p[(n//2)-1]:
        print(0)
    else:
        print(p[n//2]-p[(n//2)-1])

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

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

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

Solution (Python):
total = int(input())
element = [int(s) for s in input().split()]

element.sort()

if len(element) % 2 == 1:
  print(0)
print(element[int(len(element)/2)] - element[int(len(element)/2-1)])

Solution (Python):
N = int(input())
d = list(map(int,input().split()))
d.sort()
from bisect import bisect_left
ans = 0
for i in range(max(d)+1):
    n = bisect_left(d,i)
    if n == N//2:
        ans += 1
print(ans)

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

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

Solution (Python):
n = int(input())
p = [int(x) for x in input().split()]
p.sort()
ans = 0
half = n//2

ans = p[half] - p[half-1]

print(ans)

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

if len(d)%2 == 1:
  print(0)
else:
  d.sort()
  median = int(len(d)/2)
  print(d[median]-d[median-1])

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

Solution (Python):
import numpy as np
n=input()
S=[]
for i in input().split():
    S.append(int(i))
S=np.array(S)
word=int(int(n)/2)
asa=S.argsort()
s=int(S[asa[word]])-int(S[asa[word-1]])
print(s)

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

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

Solution (Python):
import sys

if sys.platform =='ios':
	sys.stdin=open('inputFile.txt')
		


def main():
	n = int(input())
	ll=list(map(int, input().split()))
	
	ll.sort()
	
	h=n//2
	
	return ll[h]-ll[h-1]

	

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

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

li.sort()

ind=int(n//2)-1

count=0

for k in range(li[ind]+1,li[ind+1]+1):
  count+=1
  
print(count)

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

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

sns = sorted(ns)
print(sns[n//2] - sns[n//2 - 1])

Solution (Python):





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

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

d.sort()
h_b = d[int(n/2)-1: int(n/2)]
h_a = d[int(n/2): int(n/2)+1]
print(len(range(h_b[0], h_a[0])))

Solution (Python):
import bisect
import sys

verbose = False

def test(d, k):
    sd = sorted(d)
    uniq_d = []
    pop_d = {}
    for num in sd:
        if num in pop_d:
            pop_d[num] += 1
        else:
            pop_d[num] = 1
            uniq_d.append(num)
    uniq_d = sorted(uniq_d)
    pop_uniq_d = []
    cum_pop_uniq_d = []
    prev_pop = 0
    for num in uniq_d:
        pop = pop_d[num]
        pop_uniq_d.append(pop)
        prev_pop += pop
        cum_pop_uniq_d.append(prev_pop)
    if prev_pop % 2 == 1:
        return 0
    if verbose:
        print("total pop =", prev_pop)
    target = prev_pop // 2
    if verbose:
        print("target = ", target)
    target_off = bisect.bisect_right(cum_pop_uniq_d, target)
    if verbose:
        print("target_off = ", target_off)
    if target_off == 0:
        return 0
    if verbose:
        print( "uniq_d = ", uniq_d)
        print( "cum_pop = ", cum_pop_uniq_d)
        print( "uniq_d[target_off] = ", uniq_d[target_off])
        print( "cum_pop_uniq_d[target_off] = ", cum_pop_uniq_d[target_off])
    if cum_pop_uniq_d[target_off-1] != target:
        return 0
    ans = uniq_d[target_off] - uniq_d[target_off-1]
    return ans


def main():
    rv = 0
    
    input = sys.stdin
    Nline = input.readline()
    N = int(Nline)
    args = input.readline()
    vargs = args.split()
    d = [int(arg) for arg in vargs]
    rv = test(d, N)
    print(rv)

def mock():
    rv = test( [9, 1, 4, 4, 6, 7], 6)
    print(rv)
    rv = test([9, 1, 14, 5, 5, 4, 4, 14], 8)
    print(rv)
    rv = test([99592, 10342, 29105, 78532, 83018, 11639, 92015, 77204, 30914, 21912, 34519, 80835, 100000, 1], 14)
    print(rv)

if __name__ == '__main__':
    main()

Solution (Python):

def main():
    N = int(input())
    D =[int(i) for i in input().split()]
    
    D.sort()
    D.reverse()
    center = D[int(N/2)]
    print(D[int((N/2))-1]-center)
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(map(int,input().split()))
ds=sorted(d)
n=int(N/2)
cnt=0
if ds[n]!=ds[n-1]:
    for i in range(ds[n-1],ds[n]):
        cnt+=1
print(cnt)

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

i=int(N/2)
dif=d[i]-d[i-1]

print(dif)

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

Solution (Python):

N = int(input())
d_li = list(map(int, input().split(" ")))

d_li.sort()

hn = N//2 - 1
hp = N//2 

dis = d_li[hp] - d_li[hn]

if dis == 0:
    print(0)
elif dis > 0:
    print(dis )

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

sorted_list = sorted(input_list)
half = int(n/2)
answer = sorted_list[half] - sorted_list[half-1]

print(answer)

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

s = a[(len(l)//2)] - a[(len(l)//2)-1]
print(s)

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

difficulties = [int(s) for s in input().split(' ')]

difficulties.sort()

center = num_test // 2
must_abc = difficulties[center-1]
must_arc = difficulties[center]

if must_abc == must_arc:
    print("0")
    exit(0)

print(must_arc - must_abc)
exit(0)

Solution (Python):
import numpy  as np

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

Solution (Python):

def main():
    n = int(input())
    D = sorted(map(int, input().rstrip().split()))
    h, l = D[n // 2], D[n // 2 - 1]
    print(h - l)


if __name__ == "__main__":
    main()

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

half = int((N / 2) -1)

K_under =  d[half]
K_over = d[half + 1]

K_num = K_over - K_under
print(K_num)

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

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

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

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

else:
  print(l[int(N/2)] - l[int(N/2-1)])

Solution (Python):
from heapq import nsmallest

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

m = int(-(n/2))
s = int(n/2)

m2 = sorted(p)[m]
s2 = nsmallest(s, p)[-1]

print(m2-s2)

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 = input().split()
d = [int(i) for i in d]
d = sorted(d)
ans = d[N//2] - d[N//2-1]
print(ans)

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

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

Solution (Python):
def main():
    n = int(input())
    d = list(map(int,input().split()))
    diff = d.sort()
    if len(d) % 2 == 0:
        takai = len(d)//2
        hikui = takai - 1
        ans = d[takai] - d[hikui]
        print(ans)

    else:
        print(0)

main()

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

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

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

Solution (Python):
import sys
import re
from collections import Counter

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

Solution (Python):
n=int(input())
str=input()
p_str=str.split(" ")
p=[int(tmp) for tmp in p_str]

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

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

middle = int(n / 2)

numbers1 = numbers[0:middle][-1]
numbers2 = numbers[middle:][0]

if numbers1 == numbers2:
	print("0")
else:
	print(str(numbers2 - numbers1))

Solution (Python):
N=int(input())
dlist = input().split()
dl_int = [int(n) for n in dlist]
dl_int.sort()
A =dl_int[int(N/2)]-dl_int[int(N/2)-1]
print(A)

Solution (Python):
import statistics
import math
import numpy as np

def getNearestValue(numbers, num):
    idx = np.abs(np.asarray(numbers) - num).argmin()
    for i in range(N):
        near_number= numbers[np.argsort(np.abs(np.asarray(numbers) - num))[i]]
        if near_number >= midian_number:
            near_up_number = near_number
            break
        else:
            continue
    for j in range(N):
        near_number= numbers[np.argsort(np.abs(np.asarray(numbers) - num))[j]]
        if near_number <= midian_number:
            near_under_number = near_number
            break
        else:
            continue
    return near_up_number, near_under_number
        
            


N = int(input())
numbers = [list(map(int, input().split()))]
numbers = numbers[0]

midian_number = statistics.median(numbers)

near_up_number, near_under_number = getNearestValue(numbers, midian_number)



aaa = near_up_number - midian_number
bbb = midian_number - near_under_number
print(int(aaa + bbb))

Solution (Python):
from sys import stdin

n = int(stdin.readline())
p = [int(x) for x in stdin.readline().rstrip().split()]
p.sort()

res = p[n//2] - p[n//2-1]

print(res)

Solution (Python):
n = input()
d = list(map(int,input().split()))
d_sort = sorted(d)
sa = (d_sort[int(len(d_sort) / 2)]) - (d_sort[int(len(d_sort) / 2) - 1])
arc =d_sort[int(len(d_sort) / 2):]
abc = d_sort[0:(int(len(d_sort) / 2))]
if len(arc) == len(abc):
    print(sa)
else:
    print(0)

Solution (Python):
import os, sys, re, math

N = int(input())
score = [int(s) for s in input().split(' ')]

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

Solution (Python):




from sys import stdin

N = int(stdin.readline())
P = [int(x) for x in stdin.readline().rstrip().split()]


P.sort()
center = int(N/2)
routes = P[center] - P[center - 1]
print(routes)

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

else:
    print(y-x)

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

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

Solution (Python):
import math
N = int(input())
d = list(map(int,input().split()))
ABC = []
ARC = []
d.sort()
pivot = (len(d)-1) / 2
left = math.floor(pivot)
right = math.ceil(pivot)
if d[left] == d[right]:
    K = d[left]

elif d[left] !=  d[right]:
    lists = list(range(d[left]+1,d[right]+1))
    K = lists[0]
for i in range(len(d)):
    if K <= d[i]:
        ARC.append(d[i])
    elif K > d[i]:
        ABC.append(d[i])
if len(ABC) == len(ARC):
    print(len(lists))
else:
    print("0")

Solution (Python):



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

mina = a[0]
maxa = a[-1]
l = a[:len(a)//2]
r = a[len(a)//2:]

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

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

Solution (Python):
if __name__=="__main__":
    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())
dd = list(map(int, input().split(" ")))
dd.sort()

K = int(N / 2 - 1)
if dd[K] == dd[K + 1]:
    print(0)
    exit()

res = int(dd[K + 1]) - int(dd[K])
print(res)

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

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

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

line.sort()


hil = line[(n//2) - 1]
hir = line[(n//2)]


print(hir - hil)

Solution (Python):
N = int(input())
D = list(map(int, input().split()))
D.sort()
ans = 0
for i in range(N // 2) :
  cnt = len(list(filter(lambda x : x <= D[N // 2 - 1 + i], D)))
  if(cnt == N // 2) :
    ans += D[N // 2] - D[N // 2 - 1]
  elif(cnt > N // 2) :
    break
  else :
    pass
print(ans)

Solution (Python):

n = int(input())
d = input().split()

d_int = [int(s) for s in d]


d_int.sort()


half = int(n/2)

print(int(d_int[half])-int(d_int[half-1]))

Solution (Python):

import math
def main():
	N = int(input())
	d = list(map(int,input().split()))
	d.sort()
	K = list(range(d[math.floor(N/2) - 1] + 1, d[math.floor(N/2)] + 1))
	print(len(K))

main()

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

Solution (Python):
n=0
a=[]
i=1
ii=1
l=0
tasu=0
rk=[]
bk=[]
n=int(input())
for x in input().split(" "):
    a.append(int(x))

a.sort()

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

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

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

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

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

Solution (Python):
from statistics import mean
import sys
N = int(input())
d = list(map(int,input().split()))

d.sort()

d1 = [d[i] for i in range(N//2) if i <= N]
d2 = [d[i] for i in range(N//2,N)]

a = d2[0] - d1[-1]

if len(d1) == len(d2):
    print(a)
    sys.exit()
print(0)

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

D.sort()

center = N//2

if (D[center] > D[center-1]):
    print(D[center] - D[center-1])
else:
    print(0)

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

l.sort()
if l[hn-1] == l[hn]:
    print(0)
else:
    print(l[hn]-l[hn-1])

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

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


print(in_str[cnt//2] - in_str[cnt // 2-1])

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

Solution (Python):
a = [input().split() for i in range(2)]
lis = [int(i) for i in a[-1]]
n = int(a[0][0])
lis_s = sorted(lis)

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

Solution (Python):

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

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

ds = sorted(da)

mm = ds[N//2-1]
ma = ds[N//2]

print(ma - mm)

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

Solution (Python):
N = int(input())
S = [int(x) for x in input().split()]
count=0
S.sort()

if S[int(N/2)] == S[int(N/2-1)]:
  print(count)
else:
  print(S[int(N/2)] - S[int(N/2-1)])

Solution (Python):
n = input().strip()
n = int(n)
i = list(map(int, input().split()))
i.sort()
bef = i[int((n/2) -1)]
af = i[int(n/2)]
ans = 0
min = af - bef
while(min != 0):
    ans += 1
    min -= 1
print(ans)

Solution (Python):
n = int(input())
dn = input().split()
dn = [int(s) for s in dn]
dn = sorted(dn, key=int)

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

Solution (Python):
n = int(input())
d = [int(i) for i in input().split()]
d.sort()
s=0
N=int(n/2)
k=int(abs(d[N]-d[N-1]))
K=(d[N]+d[N-1])/2
for i in range(n):
    if d[i]>=K:
        s=s+1
    else:
        s=s
if s==N:
    print(k)
else:
    print(0)

Solution (Python):
half = 0
ans = 0

N = int(input())
d = input().split(" ")
l = [int(s) for s in d]
l.sort()

half = N // 2
ans = l[half] - l[half-1]

print(ans)

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

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

if d[int((n/2)-1)] == d[int(n/2)]:
    print(0)
else:
    while k < d[int(n/2)]:
        count += 1
        k += 1
    print(count)

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

Solution (Python):
from sys import stdin

if __name__ == '__main__':

    n = int(stdin.readline())
    d = [int(x) for x in stdin.readline().rstrip().split()]

    d.sort()

    i = n // 2

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

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

list3=[]
for i in d:
  list.append(int(i))
list.sort()
if(list[int(n/2)-1]==list[int(n/2)]):
   print(0)
else :
  print(list[int(n/2)]-list[int(n/2)-1])

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

Solution (Python):
n = input()

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

if len(d) % 2:
    print(0)
else:
    h = int(len(d) / 2)
    d.sort()
    count = d[h] - d[h-1]
    print(count)

Solution (Python):
N = int(input())
input_line = [input() for i in range(1)]
d = list(map(int,input_line[0].split()))
d.sort()
half = int(len(d) / 2)
K = list(range(d[half-1]+1, d[half]+1))
print(len(K))

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

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

Data.sort()

Answer = Data[int(n/2)] - Data[int(n/2-1)]

print(Answer)

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

A.sort()
count=0
a=int(len(A)/2)

if(A[a-1]==A[a]):
  print(count)
else:
  count=A[a]-A[a-1]
  print(count)

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

l = len(D)
m = int(l/2)
D.sort()
ans = D[m] - D[m-1]
print(ans)

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

mytuple = sorted(collections.Counter(d).most_common(), key = lambda k:k[0])

mysum2 = 0 
cnt = 0
for i in mytuple:
  mynum = i[1]
  if mynum + mysum2 < N/2:
  	mysum2 += mynum
  	cnt += 1
  elif mynum + mysum2 == N/2:
    break
  elif  mynum + mysum2 > N/2:
    cnt = -999
    break

if cnt == -999:
  print(0)
else:
  print(mytuple[cnt+1][0] - mytuple[cnt][0])

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

d.sort()

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

print(b-a)

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

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

input_line = input().split(" ")
number_line = []
for i in range(0, input_num):
	number_line.append(int(input_line[i]))

number_line.sort()

temp = int(input_num/2)

print(int(number_line[temp]) - int(number_line[temp - 1]))

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

divide = 0

medium = int((len(dif)) / 2)


if (len(dif)) %2 != 0:
    print(divide)
else:
    divide = dif[medium] - dif[medium-1]
    print(divide)

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

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

nums=sorted(nums)



center=int((n/2)+1)
ans=center-1

cnt=(nums[ans]-nums[ans-1]-1)


if nums[ans]==nums[ans-1]:
    print("0")
else:
    print(cnt+1)

Solution (Python):

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

a = D[int(len(D)/2)-1:int(len(D)/2)+1]
print (a[1]-a[0])

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

if n%2==0:
    mid1=n/2
    mid2=n/2
    mid1=int(mid1-1)
    mid2=int(mid2)
    cnt=p[mid2]-p[mid1]
else:
    cnt=0

print(cnt)

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

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

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

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

if n % 2 == 0:
  d.sort()
  cnt = d[int(n/2)] - d[int(n/2)-1]

print(cnt)

Solution (Python):
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

n = int(input())
a = [int(i) for i in input().split()]
a.sort()


if is_even(n):
    print(a[int(n/2)]-a[int(n/2)-1])
else:
    print(1)

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

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

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

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

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

res = 0
for x in range(1,10**5+1):
    k = bisect.bisect_left(d,x)
    if n//2 == k:
        res += 1
print(res)

Solution (Python):
n = int(input())
d = [int(e) for e in input().split()]
d.sort()
sum = 0
if d[n//2] == d[n//2-1]:
    print(0)
    exit()
else:
    for i in range(d[n//2]-d[n//2-1]):
        
        sum+=1

print(sum)

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

List_sort =sorted(List)


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

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

Solution (Python):
import numpy as np

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

half = int(n/2)
if d_sorted[half] == d_sorted[half-1]:
    cnt = 0
else:
    cnt = (d_sorted[half]) - (d_sorted[half-1])


print(cnt)

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

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

ans = 0

li.sort()
n = int((n - 1) / 2)
ans = abs(li[n] - li[n + 1])
print(ans)

Solution (Python):
import numpy as np

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

if N%2 == 0:
    N_half = N//2
    arr = np.sort(np.array(l))
    arr_low = arr[:N_half]
    arr_high = arr[N_half:]
    if arr_low[N_half-1] != arr_high[0]:
        print(arr_high[0]-arr_low[N_half-1])
    else:
        print(0)
else:
    print(0)

Solution (Python):

n = int(input())
d_a = input().split()

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

ds = sorted(d)

mid = int(n/2) -1

if ds[mid] == ds[mid+1]:
    print(0)
    

else:
    num = ds[mid+1] -ds[mid]
    print(num)

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

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

count = 0
start = d_list[int(n / 2 - 1)]
end = d_list[int(n / 2)]

while(start < end):
    count += 1
    start += 1


print(count)

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

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

middle_idx = len(D)//2
 
diff = D[middle_idx] - D[middle_idx-1]
print(diff)