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):
import sys
from sys import stdin
import numpy as np

def main():
    
    n = int(stdin.readline())
    if n%2!=0:
        print("0")
        return
    m = int(n/2)
    
    d = np.array([int(x) for x in stdin.readline().rstrip().split()])
    d = np.sort(d)
    
    k = int(d[m])-int(d[m-1])
    print(k)
    return
    
    

if __name__ == "__main__":
    main()

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

a = int(n/2) -1
b = int(n/2)

if d_list[a] == d_list[b]:
  print(0)
else:
  print(d_list[b] - d_list[a])

Solution (Python):
N = int(input())
ls= list(map(int, input().split()))
import statistics
l = statistics.median_low(ls)
h = statistics.median_high(ls)
print(h-l)

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

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

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

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

dlist.sort()

mannaka = dlist[N//2-1] + 1
tugi = dlist[N//2]




print(tugi - mannaka + 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())
d = list(map(int, input().split()))
d.sort()

mid1 = d[n//2-1]
mid2 = d[n//2]

mid_num = mid2 - mid1
res = mid_num
mid1c = d.count(mid1)
mid2c = d.count(mid2)

if mid1 == mid2:
    res = 0
print(max(0, res))

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
ds = sorted([int(x) for x in input().split()])
print(ds[N//2]-ds[N//2-1])

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

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

Solution (Python):
s=input()
t=list(map(int,input().split()))
t.sort()
u=int(s)
v=int(u/2)
w=t[v]-t[v-1]
print(w)

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

Solution (Python):
import sys
from collections import Counter
from operator import itemgetter, attrgetter
n=0
 
n = input()
d_list= list(map(int, input().split()))
cou=sorted(Counter(d_list).most_common())
total=len(d_list)



index=0
before=0
after=0
first=True
t=0
for c in cou:

    if first:
        before = c
        first=False
    else:
        before = cou[index-1]
    after = c
    t+=c[1]
    if t > total/2:
        break
    index+=1



if not(sum(n for _, n in cou[index:]) == sum(n for _, n in cou[:index])):
    print(0)
else:
    print(after[0]-before[0])

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

nums.sort()
if n % 2 == 1:
	print(0)
else:
	m = nums[n // 2 - 1]
	l = nums[n // 2]
	print(l - m)

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

num = int(n/2)
p.sort()
med = p[num]


ans1 = list(filter(lambda x:x>=med,p))
ans2 = list(filter(lambda x:x<med,p))


cnt = 0
if len(ans1) != len(ans2):
    print(0)
else:
    for i in range(max(ans2)+1,min(ans1)+1):
        
        cnt+=1
    print(cnt)

Solution (Python):
N = int(input())
D = [int(i) for i in input().split()] 
D.sort()
M = int(N/2)
S = 0

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

Solution (Python):

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

d_sorted = sorted(d_list)

ans = int(d_sorted[harf]-d_sorted[harf-1])

print(ans)

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

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

d.sort()

a = int(int(n)/2-1)
b = int(int(n)/2)

if d[b] - d[a] > 0:
  print(d[b]-d[a])
else:
  print("0")

Solution (Python):
N=int(input())
a=list(input().split())
for i in range(N):
    a[i]=int(a[i])
a.sort()
num1=a[N//2-1]
num2=a[N//2]
ans=num2-num1
print(ans)

Solution (Python):
import numpy as np
n = input()
n = int(n)
data = input().split()
data = np.array(data)
data = data.astype(int)
data = np.sort(np.array(data))

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

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

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

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

D = sorted(D)

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

print(len(list(range(a+1, b+1))))

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

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

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

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

qlist.sort()

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

problems.sort()


print(problems[(n-1)//2+1] - problems[(n-1)//2])

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

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

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

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

Solution (Python):
import sys
import numpy as np

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

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

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

d.sort()
m1, m2 = d[int(N/2)-1], d[int(N/2)]
if m1 == m2:
    print(0)
    exit()
else:
    print(m2-m1)

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

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

Solution (Python):
n = int(input())
ls = list(map(int,input().split(" ")))
ls.sort()
num = n//2 - 1
max = max(ls)
ans = 0
if (len(ls) >= 2):
  ans = ls[num+1] - ls[num]
print(ans)

Solution (Python):
s = int(input())
n = list(map(int,input().split()))
S = []
count=0
a = len(n)//2
n.sort()

for i in range(n[a-1],n[a]):
    count+=1
print(count)

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

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


r = N // 2
l = r - 1

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

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

a = sorted(d)
b = n // 2

ans = a[b] - a[b-1]
print(ans)

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

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

Solution (Python):
K=int(input())
D=[int(x) for x in input().split()]
D.sort()
M=K/2
m=M-1
ans=D[int(M)]-D[int(m)]
print(ans)

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

Solution (Python):

n = int(input())
list = [int(i) for i in input().split(' ')]
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() 
p = int(N/2)

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

Solution (Python):
num = int(input())
difficulty = [int(i) for i in input().split()]
difficulty.sort()
K = 0
if difficulty[int(num/2)] != difficulty[int(num/2 - 1)]:
    K = difficulty[int(num/2)] - difficulty[int(num/2 - 1)]
else:
    K = 0
print (K)

Solution (Python):
import collections

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

c = collections.Counter(D)
c = sorted(c.items(), key=lambda x:x[0])

rates, counter = list(zip(*c))

acc = 0
found = False
for i in range(len(counter)):
    acc += counter[i]
    if acc == N/2:
        found = True
        break
    if acc > N/2:
        found = False
        break

if found == False:
    print(0)
else:
    print(rates[i+1]-rates[i])

Solution (Python):
N = input()
D = [int(i) for i in list(input().split())]
D.sort()
print(int(D[int(len(D)/2)])-int(D[int(len(D)/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(" ")))
a = 0
p.sort()
n_2 = int(n / 2)
abc = p[:n_2]
arc = p[n_2:]
a = arc[0] - (abc[len(abc) - 1]) 
print(a)

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

d.sort()

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

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

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

Solution (Python):



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

d.sort()


left = d[N//2 -1]
right = d[N//2]

print(right-left)

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

ABC_max = d[arc_start_index-1]
ARC_min = d[arc_start_index]

if ABC_max == ARC_min:
    print(0)
else:
    print(ARC_min - ABC_max)

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

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

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

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

C=int(N/2)-1

if d[C]!=d[C+1]:
    print(d[C+1] - d[C])
else:
    print(0)

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

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

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

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

Solution (Python):
num = int(input())
seq = input().split()

sequence = sorted([int(i) for i in seq])
a, b = len(sequence)//2-1,  len(sequence)//2

print(sequence[b]-sequence[a])

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

under = 0
uper = 0
ans = 0
d.sort()
n = int(N/2)
min = d[n-1]
mid = d[n]

low = [i for i in d if i < d[n-1]]
hi = [i for i in d if i >= d[n-1]]
if len(low) == len(hi):
    under = 1

low = [i for i in d if i < d[n]]
hi = [i for i in d if i >= d[n]]
if len(low) == len(hi):
    uper = 1

ans = d[n] - d[n-1] - 1 + under + uper
if ans < 0:
    ans = 0
print(ans)

Solution (Python):

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

d_list.sort()
mid = int(N/2)

dif = d_list[mid] - d_list[mid - 1]

print(dif)

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

li.sort()

div = li[int((n / 2))] - li[int(n / 2) - 1]

print(div)

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

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

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

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

    d.sort()
    a=d[(n//2)-1]
    b=d[(n//2)]
    ans=b-a
    print(ans)
    
main()

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

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

levels.sort()


divid_number = int(N/2)


print(levels[divid_number]-levels[divid_number-1])

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

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

Solution (Python):
n = int(input())
l = sorted([int(x) for x in input().split()])
mid = int(len(l) / 2)
med = int((l[mid-1] + l[mid]) / 2)
if l[mid] != l[mid-1]:
    print(l[mid] - l[mid-1])
else:
    print(0)

Solution (Python):
import statistics

n=int(input())
list1 = list(map(int, input().split()))
cnt = 0
ans=[]
av = statistics.median(list1)
for i in range(n):
    ans.append(abs(list1[i]-av))

fir=min(ans) 
sec=sorted(ans)[1]

print(int(fir+sec))

Solution (Python):


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

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

d_.sort()
cen = int(n/2)
num = d_[cen]-d_[cen-1]
print(str(num))

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

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

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

d.sort()

dk = d[N//2-1]

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

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

d.sort()

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

    print(c)

Solution (Python):
import numpy as np
def resolve():
    N = int(input())
    d = [int(i) for i in input().split()]
    d = np.array(d)
    d = np.sort(d)
    print(d[N // 2] - d[N // 2 - 1])
resolve()

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

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

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

Solution (Python):

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


D.sort()

upDindex = len(D)//2
lowDindex = (len(D)//2)-1


Upper = D[upDindex]
Lower = D[lowDindex]

count = Upper-Lower


print(count)

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

Solution (Python):
import sys
from itertools import accumulate

input = sys.stdin.readline


def main():
    n = int(input())
    d_list = sorted([int(i) for i in input().split()])
    print(d_list[n // 2] - d_list[n // 2 - 1])
    
    


if __name__ == "__main__":
    main()

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

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

M = N//2

x,y = D[M-1:M+1]
answer = y - x
print(answer)

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

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

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

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

Solution (Python):
import statistics
n = int(input())
d = input().split(' ')
d = [int(i) for i in d]
m = int(statistics.median(d))
nn = int(n/2) 
d.sort()
print(d[nn] - d[nn-1])

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

Solution (Python):

n = int(input())

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

d = sorted(d)

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

print(ans)

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

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

Solution (Python):
if __name__ == '__main__':
    input()
    a = list(map(int, input().split()))
    sort_a = sorted(a)
    middle = int(len(a)/2)
    count = sort_a[middle] - sort_a[middle-1]
    print(count)

Solution (Python):






import sys
import math
import array


class mymath:
    
    pi = 3.14159265358979323846264338

    
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

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

    
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()


class output:
    
    def list(self, l):
        l = list(l)
        
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()



















def main():
    
    N = int(input())
    D = [int(w) for w in input().split()]

    D.sort()

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

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

d = sorted(d)

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

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

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

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




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

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

Solution (Python):
import math
n = input()
lists = [int(i) for i in input().split()]
list.sort(lists)

mid = math.floor((len(lists))/2)
mnnaka = lists[mid]
ikkosita = lists[mid-1]

if(mnnaka==ikkosita):
    print(0)
else:
    print(mnnaka-ikkosita)

Solution (Python):
import sys
inputs = sys.stdin.readlines()
N = int(inputs[0])
d = [int(x) for x in inputs[1].split(' ')]
d.sort()

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

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

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

arr.sort()
i=int(n/2)

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

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

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

D.sort()
num = int(N//2)
count = D[num]-D[num-1]
print(count)

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

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

fir = dd[len(dd)//2-1]
sec = dd[len(dd)//2]
cou = 0
i = fir + 1




print(sec-i +1)

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

Solution (Python):
import sys

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

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

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

Solution (Python):
def divide_the_problems(N: int, D: list)->int:
    D.sort()
    return D[N//2]-D[N//2-1]


if __name__ == "__main__":
    N = int(input())
    D = [int(s) for s in input().split()]

    ans = divide_the_problems(N, D)
    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):
import numpy as np

N = int(input())

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

A_sorted = sorted(A)

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

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

Solution (Python):
N = int(input())
D = list(map(int, input().split()))
D.sort()
Dlen = len(D)
ans = D[Dlen // 2] - D[Dlen // 2 - 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):

if __name__=='__main__':
    n = int(input())
    m = int(n/2)
    d = [int(x) for x in input().split()]
    d.sort()
    print(d[m]-d[m-1])

Solution (Python):


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

left = l[int(N / 2) - 1]
right = l[int(N / 2)]

ans = right - left

print(ans)

Solution (Python):
def main():
    n = int(input())
    ds = input().split()
    if n % 2:
        print(0)
        return

    nds = sorted(list(map(lambda x: int(x), ds)))
    print(nds[n//2] - nds[(n//2)-1])


if __name__ == '__main__':
    main()

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

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

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

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

if __name__ == '__main__':
    main()

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

d.sort()
print(d[CEN]-d[CEN-1])

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

d.sort()

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

Solution (Python):
import sys


def main():
    n = int(sys.stdin.readline().strip())
    ds = sys.stdin.readline().strip()
    d = [int(s) for s in ds.split()]
    sorted_d = sorted(d)

    left = sorted_d[n // 2 - 1]
    right = sorted_d[n // 2]
    print(right - left)


if __name__ == '__main__':
    main()

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

Solution (Python):

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

Solution (Python):

N= map(int, input().split())
d = list(map(int, input().split()))
sort_d =sorted(d)
len_d = len(d)
half_low = int(len_d/2-1)
half_up = int(len_d/2)
ans =sort_d[half_up]-sort_d[half_low]
print(ans)

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

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

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

B = sorted(list_A)
half = int(num/2)
left = B[half-1]
right = B[half]
if left == right:
    ans = 0
else:
    ans = right-left

print(ans)

Solution (Python):
num = int(input())
array = list(map(int, input().split()))

sort_list = sorted(array)
num_ha = int(num /2)

print(sort_list[num_ha]-sort_list[num_ha -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())
l = list(map(int,input().split()))

ans = 0






        
l_s = sorted(l)
diff = l_s[int(len(l_s)/2)] - l_s[int(len(l_s)/2)-1]
if diff > 0:
    print(diff)
else:
    print(0)

Solution (Python):
n = int(input())
d = list(map(int, input().split()))
d.sort()
k_count = 0
i = n // 2 - 1
arc = len(list(filter(lambda x: x > d[i], d)))
abc = len(list(filter(lambda x: x <= d[i], d)))
if arc == abc:
    k_count += (d[i+1] - d[i])
print(k_count)

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

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

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

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

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

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

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

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

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

Solution (Python):
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):
def resolve():
    N = int(input())
    D = sorted(list(map(int, input().split())))
    idx = len(D) // 2
    mid = D[idx]
    low = D[idx - 1]
    if mid == low:
        print(0)
        return

    print(mid - low)

resolve()

Solution (Python):
import re
import numpy as np


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

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

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

Solution (Python):
N = int(input())
d = list(map(int, input().split()))
s = sorted(d)
half = N//2
answer = s[half-1] 
count = 0
i = 0
while answer + i <= s[half]:
  count += 1
  i += 1
print(count-1)

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


m = sorted(l)
if len(m)%2!=0:
    print(0)
else:
    i = len(m)//2 -1
    ans = m[i+1]-m[i]
    print(ans)

Solution (Python):
import math

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

center=int((n/2)-1)
print(sorted_d[center+1]-sorted_d[center])

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

numbers = sorted(numbers)

diff_half_n = numbers[int(n/2)-1]
diff_half_n_plus_1 = numbers[int(n/2)]

print(diff_half_n_plus_1 - diff_half_n)

Solution (Python):
N = int(input())
a = input()
k = 0
list1 = list(map(int,a.split()))

list1.sort()

k = list1[int(N/2)] - list1[int(N/2)-1] 
print(k)

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


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

Solution (Python):










n=int(input())
lis=list(map(int,input().split()))
lis.sort()
half=int(n/2)
a=lis[half-1]
b=lis[half]
delta=b-a
ans=delta

print(ans)

Solution (Python):


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

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

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

d.sort()

cut = int(n/2)

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

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

d = input().split(" ")
for i, dd in enumerate(d):
    d[i] = int(dd)

d_sort = sorted(d) 

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

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

c = sorted(b)

i = int(len(c) / 2)

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

Solution (Python):


def main():
    
    
    
    
    
    
    
    
    N = int(input())
    d_list = list(map(int, input().split()))
    sorted_d = sorted(d_list)
    print(sorted_d[N//2]-sorted_d[N//2-1])



if __name__=='__main__':
    main()

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

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

d.sort()



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

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


if __name__ == "__main__":
    main()

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

d.sort()

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

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

a_s = sorted(a)
half = N//2

upper = a_s[half]
under = a_s[half-1]

ans = upper - under

print(ans)

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

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

x2=sorted(x)

n1=int(n/2-1)
n2=int(n/2)

if x2[n1]==x2[n2]:
	cnt=0
else:
	cnt=x2[n2]-x2[n1]

print(cnt)

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

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

Solution (Python):
a = int(input())
b = list(map(int,input().split()))
b.sort()
c = b[int(a/2)] - b[int(a/2)-1]
if c > 0:
    print(c)
else:
    print(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=list(map(int,input().split()))
d.sort(reverse = True)
print(d[int(N/2)-1]-d[int(N/2)])

Solution (Python):



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

difficulty = sorted(array_d)

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

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

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

d_sort = sorted(d)

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