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
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque


from collections import Counter

from itertools import accumulate,combinations,permutations

from heapq import heapify,heappop,heappush


from functools import lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

    N = int(input())
    
    d = list(map(int, input().split())) 
    
    
    d.sort()
    md=d[-1]
    count=0
    for i in range(1,md+1):
        c=bisect_left(d,i)
        if N-c==c:
            count+=1
    print(count)





if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
d=list(map(int,input().split()))
d.sort()
ABC=[]
ARC=[]
for i in range(n):
    if i<n//2:
        ABC.append(d[i])
    else:
        ARC.append(d[i])
if max(ABC)==min(ARC):
    print(0)
else:
    num=abs(max(ABC)-min(ARC))
    print(num)

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

dl.sort()
d_half1 = dl[n//2-1]
d_half2 = dl[n//2]

print(d_half2-d_half1)

Solution (Python):
n, *dd = map(int, open(0).read().split())

dd.sort()

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

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

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

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

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):
N = int(input())
d = list(map(int,input().split()))
k = 0
d.sort()
if len(d) % 2 == 1:
    k = 0
elif d[int(len(d) / 2)] == d[int((len(d) / 2) - 1)]:
    k = 0
else:
    k = d[int(len(d) / 2)] - d[int((len(d) / 2) - 1)]

print(k)

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

brr=sorted(arr)

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

print(ans)

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

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

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

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

Solution (Python):
a = int(input()) // 2
N = input().split(" ")
N = (int(s) for s in N)
N = sorted(N)
bet = N[a] - N[a - 1]
print(bet)

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

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

Solution (Python):








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

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

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
d_li = [int(w) for w in input().split()]
d_li.sort()

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

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

index = len(d) // 2 - 1

ans = 0
if d[index] != d[index + 1]:
    ans = d[index + 1] - d[index]
    
print(ans)

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

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

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

n_1=int(N/2)-1
n_2=int(N/2)
print(D[n_2]-D[n_1])

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

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

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

Solution (Python):









import os
import sys




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

    if len(d)%2 == 1:
        print(0)
        return
    l = d[len(d)//2-1]
    r = d[len(d)//2]
    if l == r:
        print(0)
        return
    print(r-l)



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

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

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

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

Solution (Python):
n,*l=map(int,open(0).read().split())
n//=2
l.sort()
print(l[n]-l[~n])

Solution (Python):
n,*d=map(int,open(0).read().split())
l,r=sorted(d)[n//2-1:n//2+1]
print(r-l)

Solution (Python):

N=int(input())
d=[int(x) for x in input().split()]
d.sort()
if N%2==1:
    print(0)
    exit(0)
x,y=d[N//2-1:N//2+1]
print(y-x)

Solution (Python):

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

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

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

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

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

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

d.sort()

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

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

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

Solution (Python):
import sys

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

if N % 2 != 0:
    print(0)
    sys.exit()

low  = D[0:N//2]
high = D[N//2::]

flg  = all( low[-1] + 1 >  x for x in low )
flg |= all( high[0] - 1 >= x for x in high )

if flg == True:
    print(high[0] - low[-1])
else:
    print(0)

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

Solution (Python):
nb = int(input())
liste=[int(x) for x in input().split()]
liste.sort()
index1 = (nb//2)-1
index2 = (nb//2)
roger =liste[index2]-liste[index1]
print(roger)

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

d_sorted = sorted(D)

na = d_sorted[int(N/2)]
nb = d_sorted[int(N/2-1)]

print(na-nb)

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

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

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

d.sort()

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

print(ans)

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

d.sort()

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

Solution (Python):
n = int(input())
d = sorted(list(map(int,input().split())))
x = int(n/2)
abc = d[:x]
arc = d[x:]
cnt = 0
for i in range(max(abc)+1, min(arc)+1):
    cnt += 1

print(cnt)

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict



sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    D = sorted(il())
    l = D[N // 2 - 1]
    r = D[N // 2]
    print(r - l)


if __name__ == '__main__':
    main()

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

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

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

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

if d[ind-1]==d[ind]:
  print(0)

else:
  print(d[ind]-d[ind-1])

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

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

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *D = map(int, read().split())
    D.sort()

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


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
d=list(map(int,input().split()))
d=sorted(int(i) for i in 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):
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())
S = list(map(int, input().split()))
S.sort()
print(S[N//2]-S[N//2-1])

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

max_n = max(d[:n2])
min_n = min(d[n2:])

ans = 0
for i in range(max_n+1,min_n+1):
    ans += 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):
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()
s=n//2-1
a=d[s]
b=d[s+1]
if a==b:
  print(0)
  
else:
  print(b-a)

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

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

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

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

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

if N % 2 != 0:
  print(0)
else:
  middle = N // 2 
  answer = d_list[middle] - d_list[middle - 1]
  print(answer)

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

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

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

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

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

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

Solution (Python):
def count_up(d, cut):
    ARC = len([1 for i in d if i >= cut])
    ABC = len(d) - ARC
    if ABC == ARC:
        return True
    return False

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

Solution (Python):




from __future__ import division, print_function 

import sys
import os
from collections import Counter, deque, defaultdict
import itertools
import math
import io


"""Uncomment modules according to your need"""













if sys.version_info[0] < 3:
    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip



"""value of mod"""
MOD = 998244353
mod = 10**9 + 7

"""Uncomment next 4 lines if doing huge recursion"""




def prepare_factorial(mod=mod):
    """ returns two lists, factorial and inverse factorial modulo argument by default 10**9 +7 """
    
    fact = [1]
    for i in range(1, 200005):
        fact.append((fact[-1] * i) % mod)

    ifact = [0] * 200005
    ifact[200004] = pow(fact[200004], mod - 2, mod)
    for i in range(200004, 0, -1):
        ifact[i - 1] = (i * ifact[i]) % mod

    return fact, ifact

def modinv(n, p):
    """ returns N inverse modulo p """
    return pow(n, p - 2, p)

def ncr(n, r,  fact, ifact):
    """ takes 4 arguments: n , r and factorial and inverse factorial lists"""
    t = (fact[n] * (ifact[r]*ifact[n-r]) % MOD)% MOD
    return t


def get_n(Sum):    
    """this function returns the maximum n for which Summation(n) <= Sum"""
    ans = (-1 + sqrt(1 + 8*Sum))//2
    return ans

def sieve(n):
    """ returns a list of prime numbers till n """
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r



def divs(n, start=1):
    """ returns a list of all divisors till n """
    divisors = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if n % i == 0:
            if n / i == i:
                divisors.append(i)
            else:
                divisors.extend([i, n // i])
    return divisors



def divn(n, primes):
    """ returns the number of divisors, two arguments n and the sieve till n """
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t



def lrfind(d, x, default=-1):
    """ Takes 2 arguments an iterable and an element. returns a tuple (firstoccurence,lastoccurence) -1 if not found """
    left = right = -1
    for i in range(len(d)):
        if d[i] == x:
            if left == -1: left = i
            right = i
    if left == -1:
        return default, default
    else:
        return left, right

def gcd(x, y): 
    """ returns greatest common divisor of x and y """
    while y:
        x, y = y, x % y
    return x

def check_sorted(a):
    ''' returns True/False '''
    for i in range(len(a)-1):
        if a[i]>a[i+1]:
            return False
    return True
def ceil(n, k=1): return n // k + (n % k != 0) 
def input(): return sys.stdin.readline().strip()
def ii(): return int(input()) 
def mi(): return map(int, input().split()) 
def li(): return list(map(int, input().split())) 
def lw(): return input().split() 
def lcm(a, b): return abs(a * b) // gcd(a, b) 
def prr(a, sep=' ', end='\n'): print(sep.join(map(str, a)), end=end) 
def dd(): return defaultdict(int) 
def ddl(): return defaultdict(list) 
def write(s): return sys.stdout.write(s)













def main():
    
    n=ii()
    k=li()
    k.sort()
    print(k[n//2]-k[n//2-1])

""" -------- Python 2 and 3 footer by Pajenegod and c1729 ---------"""

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192

class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill();
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):

    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s: self.buffer.write(s.encode('ascii'))
            self.read = lambda: self.buffer.read().decode('ascii')
            self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')



""" main function"""

if __name__ == '__main__':
    main()

Solution (Python):
def actual(n, D):
    D.sort()

    idx = int(len(D) // 2)
    abc_max = D[:idx][-1]
    arc_min = D[idx:][0]

    k = 0

    for i in range(abc_max + 1, arc_min + 1):
        k += 1

    return k

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

print(actual(n, D))

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

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

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

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

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

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

def main():
    n = int(input())
    D = sorted(map(int, input().split()))
    abc = D[:n//2]
    arc = D[n//2:]
    print(arc[0] - abc[-1])



main()

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

count = 0
count2 = 0
d.sort()

le = len(d)//2
s = d[int(le)-1]
l = d[int(le)]
ans = 0
for i in range(s,l):
  ans += 1
if(ans == ""):
	print(0)
else:
    print(ans)

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

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

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

d1, d2 = D[n // 2 - 1], D[n // 2]
ans = 0
if d1 != d2:
    ans = len(range(d1 + 1, d2 + 1))

print(ans)

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

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

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

Solution (Python):
import sys


def main():
    n = int(sys.stdin.readline())
    d = list(map(int, sys.stdin.readline().split()))
    d.sort()
    h = n // 2
    print(d[h] - d[h - 1])


if __name__ == "__main__":
    main()

Solution (Python):
import sys


def main():
    n = int(sys.stdin.readline())
    d = list(map(int, sys.stdin.readline().split()))
    d.sort()
    half = n // 2
    print(d[half] - d[half - 1])


if __name__ == "__main__":
    main()

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


if __name__ == "__main__":
    main()

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

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

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

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

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

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

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

k_1 = l[(n//2)-1]
k_2 = l[(n//2)]
print(k_2-k_1)

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

l.sort()
mid_id = int((N / 2) - 1)
ans = l[mid_id+1] - l[mid_id]

print(ans)

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

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

H=int(N//2)

for i in range(1,10**5+1):
    if li[H-1]<i and li[H]>=i:
        ans+=1

print(ans)

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

def mergesort(a):
    def _merge_sort(a, left: int, right: int):
        if left < right:
            center = (left+right)//2

            _merge_sort(a,left,center)
            _merge_sort(a,center+1,right)

            
            p=j=0
            i=k=left

            
            while i <= center:
                buff[p]=a[i]
                p+=1
                i+=1

            
            while i<= right and j < p:
                if buff[j] <= a[i]:
                    a[k]=buff[j]
                    j+=1
                else:
                    a[k]=a[i]
                    i+=1
                k+=1

            while j < p:
                a[k] =buff[j]
                k+=1
                j+=1

    n=len(a)
    
    buff=[None]*n
    _merge_sort(a,0,n-1)
    del buff

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

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

d.sort()

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

print(ans)

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

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

Solution (Python):
def main():
    n = int(input())
    d = list(map(int, input().split()))
    d_s = sorted(d)
    idx = int(n/2)
    diff = d_s[idx] - d_s[idx-1]
    print(diff)
    
if __name__ == '__main__':
    main()

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

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

    if n % 2 != 0:
        ans = 0
    else:
        mid = n // 2
        ans = ds[mid] - ds[mid-1]
    print(ans)


if __name__ == "__main__":
    main()

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

l,r = D[N//2-1],D[N//2]
if l==r:
  print(0)
  exit()

print(r-l)

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

D.sort()

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

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
a = rl()
a.sort()
i = n//2
print(a[i] - a[i-1])

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

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

Solution (Python):
import sys

input = lambda: sys.stdin.readline().rstrip()


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


if __name__ == '__main__':
    solve()

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

Solution (Python):
n = int(input())
l = [int(_) for _ in input().split()]
l = sorted(l)
a = l[n // 2 - 1]
b = l[n // 2]
print(b - a)

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

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

d = sorted(d)

e = int(n/2-1)
f = int(n/2)


s = d[e]
t = d[f]
if s == t:
    print(0)
else:
    print(t-s)

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()
nn = int(n / 2)
print(d[nn] - d[nn - 1])

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

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

d.sort()

d_len = len(d)
d_center = d_len // 2

if d[d_center-1] == d[d_center]:
    print(0)
else:
    print(d[d_center]-d[d_center-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())
d = list(map(int, input().split()))

half_ind = int(len(d)/2)
L = sorted(d)[half_ind-1]
R = sorted(d)[half_ind]

print(R - L)

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

list.sort(d_array)

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

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

d.sort()
mind = d[n//2-1]
maxd = d[n//2]

ans = maxd - (mind + 1) + 1
if ans < 0:
    print(0)
    exit()
print(ans)

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

print(B-A)

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


if __name__ == '__main__':
    main()

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

print(ans)

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

Solution (Python):
def resolve():
    N = int(input())
    d = list(map(int, input().split()))
    d.sort()
    ans = d[int(N / 2)] - d[int((N - 1) / 2)]
    if ans < 1:
        print(ans)
        return
    print(ans)
resolve()

Solution (Python):


import sys
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
d.sort()

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

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

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

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

Solution (Python):
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

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

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

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

print(K)

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

if lis[int(n/2)-1] == lis[int(n/2)]:
    print(0)
else:
    a = list(range(lis[int(n/2)-1]+1, lis[int(n/2)]+1))
    print(len(a))

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

mid1 = N // 2 - 1
mid2 = mid1 + 1
print(D[mid2] - D[mid1])

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    d = list(map(int, input().split()))
    d.sort()
    print(d[n // 2] - d[n // 2 - 1])


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

Solution (Python):
def solve(N,d):
  if N % 2 == 1:
    return 0
  else:
    arc = d[N//2:]
    abc = d[:N//2]
    return arc[0] - abc[-1]

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

print(solve(N,d))