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):
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


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

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

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

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

if lst[N//2-1] - lst[N//2] == 0:
    print(0)
    exit()
print(lst[N//2] - lst[N//2-1])

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

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

Solution (Python):
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


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

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


if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    n = II()
    d = LI()

    d.sort()

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


main()

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

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

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

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

print(ans)

Solution (Python):

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

i_min = n//2 -1
i_max = n//2
v_min = d[i_min]
v_max = d[i_max]

print(v_max-v_min)

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

Solution (Python):



def solv(n, d):
    d = sorted(d)
    min_ = d[n // 2 - 1] + 1
    max_ = d[n // 2]
    if min_ > max_:
        return 0
    else:
        return max_ - min_ + 1



if __name__ == '__main__':

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

    ans = solv(n, d)

    print(ans)

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

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

dlist.sort()

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

Solution (Python):
import numpy as np

n = int(input())  
d = np.array(input().split(), dtype=np.int64)

d_sort = np.sort(d)
d_size = len(d)


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

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

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

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

d.sort()

if N % 2 == 1:
    print(0)
else:
    l = d[N // 2 - 1]
    r = d[N // 2]
    
    ans = r - l
    if ans > 0:
        print(ans)
    else:
        print(0)

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

Solution (Python):


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

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

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

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

left = N // 2 -1
right = N // 2

print(D_sorted[right] - D_sorted[left])

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

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

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

ABC_upper = num[n//2-1]
ARC_lower = num[n//2]

print(ARC_lower - ABC_upper)

Solution (Python):
input()

x=list(map(int,input().split(' ')))

x=sorted(x,reverse=True)

temp1=x[int(len(x)/2)-1]
temp2=x[int(len(x)/2)]

print(temp1-temp2)

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

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

Solution (Python):
def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	d = list(map(int, input().split()))
	d.sort()
	ind = int(N/2)
	if d[ind-1] == d[ind]:
		print(0)
	else:
		print(d[ind] - d[ind-1])

if __name__ == '__main__':
    main()

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

mid = n // 2

lower = d[mid - 1]
upper = d[mid]
diff = upper - lower
print(diff)

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

mannaka = int(N/2)

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

DDD.sort()

left = DDD[:mannaka][-1]
right = DDD[mannaka:][0]

print(right-left)

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

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

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

Solution (Python):


def solve():
    N = int(input())
    D = list(map(int, input().split()))
    D.sort()

    """
    1 4 4 | 6 7 9　OK

    1 4 4 | 4 7 9　だめ

    1 2 3 | 3 7 9  だめ
    """

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

    print(ans)


if __name__ == "__main__":
    solve()

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
D=LIST()

D.sort()
D1=D[:N//2]
D2=D[N//2:]

print(D2[0]-D1[-1])

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

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

if N % 2 == 1:
    print(0)
    quit()


D.sort()

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

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

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

d.sort()

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

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

N = int(input())
d = list(map(int, input().split()))
d.sort()
if len(d)%2 == 0:
    print(d[int((N-1)/2 + 1)] - d[int((N-1)/2)])
elif len(d)%2 == 1:
    print(0)

Solution (Python):
import bisect
N = int(input())
Ds = sorted(list(map(int,input().split())))
index = len(Ds)//2
if Ds[index]== Ds[index-1]:
    print(0)
else:
    print(Ds[index]-Ds[index-1])

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

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

e = xs[n//2] 
b = xs[n//2-1]

print(e-b if e != b else 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 = sorted([int(d) for d in input().split()])

n_d2 = int(n / 2)

sa = D[n_d2] - D[n_d2 -1]
print(sa)

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

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

    print(right_mid - left_mid)

Solution (Python):
import bisect

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

d.sort()

cnt = 0
for i in range(1, 10**5+1):
    index = bisect.bisect_left(d, i)
    if N - index == index:
        cnt += 1

print(cnt)

Solution (Python):
N = int(input())
d_list = sorted([int(x) for x in input().split()])
print(d_list[N//2] - d_list[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())
dn = list(map(int, input().split()))
dn.sort()
d1, d2 = dn[n//2-1:n//2+1]
print(d2-d1)

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

e = xs[n//2] 
b = xs[n//2-1]

print(e-b if e != b else 0)

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):
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)

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

Solution (Python):
import bisect

n = int(input())
d = list(map(int, input().split()))
d.sort()
div = n // 2
count = 0
for i in range(10**5 + 1):
    insert_index = bisect.bisect_right(d, i)
    if insert_index == div:
        count += 1
print(count)

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

m = n // 2

abc = ds[:int(m)]
arc = ds[int(m):]

print(arc[0] - abc[-1])

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

Solution (Python):
import sys

fin = sys.stdin.readline
n = int(fin())
d_list = [int(elem) for elem in fin().split()]

sort_d = sorted(d_list)
middle_d = int(n / 2)

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

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

Solution (Python):
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10



N = int(stdin.readline().rstrip())
d = list(map(int, stdin.readline().rstrip().split()))

d.sort()

right = N // 2
left = right - 1

print(d[right] - d[left])

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 = [int(d) for d in input().split()]
D.sort()
a,b = D[n//2-1], D[n//2]
print(b-a)

Solution (Python):
import bisect
N = int(input())
d_lis = sorted([int(item) for item in input().split()], reverse=False)

count = 0
for i in range(100000):
    if bisect.bisect(d_lis, i) == N / 2:
        count += 1
print(count)

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

Solution (Python):
inp = input()
n = int(inp)
inp = input()
split_inp = inp.split()
d_list = [int(st) for st in split_inp]
if n % 2 == 1 or n < 2:
    print(0)
    exit()
half = n // 2
d_list = sorted(d_list)
print(d_list[half] - d_list[half-1])

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

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

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

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

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

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

Solution (Python):
N = int(input())
difficulty = [int(x) for x in input().split()]
center = N//2

difficulty = sorted(difficulty)

ans = difficulty[center]-difficulty[center-1]

print("{}".format(ans))

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

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

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

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

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

half = N//2
ds = sorted(ds)
ret = ds[half] - ds[half-1]
print(ret)

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

d.sort()
h = int(N/2)

pre = d[h-1]
pos = d[h]

if pre==pos:
    print(0)
else:
    print(pos-pre)

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

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

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

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

Solution (Python):



import sys  
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools



sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe


def local_input():
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)


def solve():
    n = int(input())
    l = list(map(int,input().split()))
    l = sorted(l)
    m = n // 2 - 1
    if l[m] == l[m+1]:
        print(0)
    if l[m] < l[m+1]:
        print(l[m+1]-l[m])
        
    return 0

if __name__ == "__main__":
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

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


main()

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

print(solve())

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

Solution (Python):


def do():
    n = int(input())
    ds = list(map(int, input().split(" ")))
    ds.sort()
    sita = ds[n//2-1]
    ue = ds[n//2]
    print(ue-sita)

if __name__ == "__main__":
    do()

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

d.sort()

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

Solution (Python):
def resolve():
    N = int(input())
    ds = list(map(int, input().split(" ")))
    ds.sort()
    print(ds[int(N/2)] - ds[int(N/2)-1])
    
if '__main__' == __name__:
    resolve()

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

li.sort()
ind = n//2
min = li[ind-1]
max = li[ind]


print(max-min)

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


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

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

d.sort()

if len(d) %2 == 1:
  print(0)
  exit()
le = len(d)
mi = d[int(le/2) - 1]
ma = d[int(le/2)]

print(ma-mi)

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

l = len(sorted_ds)
i = int(l/2)
print((sorted_ds[i] - sorted_ds[i-1]) if l % 2 == 0 else 0)

Solution (Python):
import sys

N = int(input())

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

d.sort()

b = (N+1) // 2
a = b - 1

d1 = d[a]
d2 = d[b]

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

print(d2 - d1)

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

d = sorted(d)

ABC_max = int((N / 2) - 1)
ARC_min = int(N / 2)

ans = d[ARC_min] - d[ABC_max]

print(ans)

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

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

Solution (Python):
from bisect import bisect_left

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

to_take = N // 2

cnt = 0
for x in range(d[0], d[-1] + 1):
    idx = bisect_left(d, x)
    
    if idx == to_take:
        cnt += 1
print(cnt)

Solution (Python):
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    N = int(input())
    D = [int(c) for c in input().split()]
    sorted_D = sorted(D)
    upper = sorted_D[N//2]
    lower = sorted_D[N//2 - 1]
    print(upper - lower)


if __name__ == '__main__':
    main()

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

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

d = sorted(d)

h = int(n/2)

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

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


N=int(input())
d=acinput()


d=sorted(d)

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

Solution (Python):
import sys
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))
N = int(input())
d = sorted(inpl())
if N % 2:
    print(0)
else:
    print(d[N//2]-d[N//2-1])

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

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

d = sorted(d)

m = d[N // 2 - 1]
l = d[N // 2]

print(l-m)

Solution (Python):
words = lambda t : list(map(t, input().split()))
n = int(input())
a = words(int)
a.sort()

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

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

maxK = D[N // 2]
minK = D[N // 2 - 1]

print(maxK - minK)

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

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

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

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


abc = ds[:n//2]
arc = ds[n//2:]



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

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

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

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

d.sort()

c = int(n / 2 - 1)

print(d[c+1] - d[c])

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

ls = sorted(ls)

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

Solution (Python):
def main():
    n = int(input())
    d = [int(e) for e in input().split(" ")]
    d.sort()
    n2 = int(n/2)

    if(d[n2] == d[n2-1]):
        print("0")
    else:
        print(d[n2] - d[n2-1])

if __name__ == "__main__":
    main()

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

d = sorted(d)

u = d[N//2]
l = d[N//2 - 1]

print(u - l)

Solution (Python):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy




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

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
s=list(map(int,input().split()))
i=1
ans=0

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

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

print(l-s)

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

Solution (Python):
import sys

def main():
    n = int(sys.stdin.readline().strip())
    d = [int(i) for i in sys.stdin.readline().strip().split()]
    d.sort()
    return d[n//2] - d[n//2-1]
    
print(main())

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

d = sorted(d)

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

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

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

D.sort()
minsaigo = D[N//2-1]
maxsaisho = D[N//2]

if minsaigo == maxsaisho:
    print(0)

else:
    K = maxsaisho - minsaigo

    print(K)

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

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

p2 = sorted(p)

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

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

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


def solve():
    left = D[N // 2 - 1]
    right = D[N // 2]
    if left == right:
        return 0
    return right - left


print(solve())

Solution (Python):
def main():
    _ = int(input())
    d = [int(s) for s in input().split()]
    print(solve(d))

def solve(d):
    ds = sorted(d)
    n = len(ds)

    return ds[n // 2] - ds[n // 2 - 1]

main()

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

sm = d[N//2 - 1]
la = d[N//2]

print(la-sm)

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

d = sorted(d)

i = N//2 - 1
j = N//2

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

Solution (Python):
import sys
n = int(input())
p = [int(x) for x in input().split()]
if n % 2 != 0:
    print(0)
    sys.exit()
p.sort()
a,b = p[n//2 - 1],p[n//2]
print(b-a)

Solution (Python):
a = int(input())
b = list(map(int,input().split()))
c = sorted(b)
print(c[int(0.5*a)]-c[int(0.5*a-1)])

Solution (Python):



from __future__ import print_function


try:
    input = raw_input
    range = xrange
except NameError:
    pass






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


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

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

d_array.sort()

min_K = d_array[N // 2 - 1] + 1
max_K = d_array[N // 2]

print(max(max_K - min_K + 1, 0))

Solution (Python):

n = int(input())
num_list = sorted([ int(v) for v in input().split() ])

ans = 0


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

Solution (Python):
n = int(input())
d = list(map(int, input().split(' ')))
d.sort()
d1 = [d[i] for i in range(n//2)]
d2 = [d[i] for i in range(n//2,n)]
print(d2[0]-d1[-1])

Solution (Python):


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


if __name__ == '__main__':
    solve()

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

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

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

Solution (Python):


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

    ds.sort()
    mid = N // 2

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


if __name__ == '__main__':
    main()

Solution (Python):


import sys

class CDivideTheProblems:
    def solve(self):
        n = int(input())
        d = [int(_) for _ in input().split()]
        d.sort()
        if n % 2 == 0:
            print(d[(n - 1) // 2 + 1] - d[(n - 1) // 2])
        else:
            print(1)

solver = CDivideTheProblems()
input = sys.stdin.readline

solver.solve()

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

d.sort()

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

Solution (Python):


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

d.sort()

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

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

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

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

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

mid=n//2

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

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

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

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

Solution (Python):
def main():
    N = int(input())
    ds = sorted(map(int, input().split(" ")))

    half = N // 2
    if ds[half-1] == ds[half]:
        return 0

    out = ds[half] - ds[half-1]
    return out

out = main()

print(out)

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))

n = onem()
l = l()
if n % 2 == 1:
    print(0)
    exit()
co = 0
l.sort()
ll = [0 for i in range(10**5+1)]

for i in range(n):
    ll[l[i]] += 1

for i in range(1,len(ll)):
    ll[i] += ll[i-1]
    if ll[i] == n//2:
        co += 1
print(co)

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

if d[l] == d[r]: print(0)
else:
    print(d[r]-d[l])

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

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

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

Problems = D[:]
Problems = sorted(Problems)

abc = Problems[N // 2 -1]
arc = Problems[N // 2]



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

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

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

ds.sort()

half = n // 2 - 1
k_min = ds[half]
k_max = ds[half+1]

print(k_max-k_min)

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