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 __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


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

    n >>= 1
    x = d[n] - d[n - 1]
    print(x)




BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

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

ds.sort()

print(ds[N//2] - ds[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):
N = int(input())

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

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    
    n = int(input())
    arr = sorted(map(int, input().split()))
    
    
    print(arr[n // 2] - arr[n // 2 - 1])
    
    return 0

main()

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

d.sort()

s = d[N//2-1]
t = d[N//2]

print(t-s)

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

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

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

dlist=sorted(dlist)


manaka=int(n/2)

sho=dlist[manaka-1]
dai=dlist[manaka]


if sho==dai:
    print(0)
else:
    print(dai-sho)

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

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

Solution (Python):
def find(A):
    A=sorted(A)
    N=len(A)
    left=A[:N//2]
    right=A[N//2:]
    a=left[-1]
    b=right[0]
    return b-a
input()
A=list(map(int,input().strip().split(' ')))
print(find(A))

Solution (Python):
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 = sorted(d)
ans = D[N // 2] - D[N // 2 - 1]

print(ans)

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
d = sorted(list(map(int, input().split())))
c2 = N // 2
c1 = c2 - 1
print(d[c2] - d[c1])

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

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

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

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

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

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

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

Solution (Python):

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

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

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

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

abc_last = ds[n//2-1]
arc_first = ds[n//2]

k = arc_first - abc_last
print(k)

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

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

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

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

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


n = ni()
d = list(li())
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)
min_ans = d[n//2-1]
max_ans = d[n//2]

print(max_ans - min_ans)

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

print(max(r-l,0))

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



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

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

Solution (Python):
import numpy as np
from collections import defaultdict
from functools import reduce

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):
def main():
    n = int(input())
    d = list(map(int, 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)
mi = D[N // 2 - 1]
ma = D[N // 2]
if mi == ma:
    print(0)
else:
    print(ma - mi)

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

def inpl(): return list(map(int, input().split()))
from collections import Counter
N = int(input())
D = sorted(inpl())
print(D[N//2] - D[N//2-1])

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
d = LIST()

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

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


mid1 = arr[(n//2) - 1]
mid2 = arr[(n//2)]

print(mid2 - mid1)

Solution (Python):
n = int(input())
d = [int(i) for i in 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()
d = D[(N//2)]-D[(N//2)-1]
print(d)

Solution (Python):
N = int(input())
d = [int(s) for s 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()

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

Solution (Python):



n=int(input())
l=list(map(int,input().split()))
flg=0
l.sort()
if n%2!=0:
    flg=1
ans=l[n//2]-l[n//2-1]
if flg==0:
    print(ans)
else:
    print(0)

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

Solution (Python):
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)










n = ip()
a = iprow()
a.sort()
if a[n//2-1] == a[n//2]:
    print(0)
else:
    print(a[n//2]-a[n//2-1])

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


d.sort()

idx1 = n//2 - 1

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

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

Solution (Python):
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]






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

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

Solution (Python):

import sys
from operator import itemgetter

from fractions import gcd

from math import ceil, floor

from copy import deepcopy

from itertools import accumulate






from collections import Counter
import math
from functools import reduce




input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())



def solve(N: int, d: "List[int]"):
    d.sort()
    print(d[N // 2] - d[N // 2 - 1])


def main():

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


if __name__ == '__main__':
    main()

Solution (Python):
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op



inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    D = get_li()
    D.sort()
    a, b = D[len(D) // 2 - 1], D[len(D) // 2]
    print(b - a)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

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):
import sys
input = sys.stdin.readline

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

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



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

Solution (Python):


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


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
n = int(input())
listD = list(map(int, input().split()))
listD.sort()
length = len(listD)//2

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

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

ans = 0
for i in range(10**5+5):
    j = bisect(D, i)
    if j==N//2:
        ans += 1
    elif j>N//2:
        break
print(ans)

Solution (Python):



from math import *

def main():
    import sys
    sys.dont_write_bytecode = True
    sys.setrecursionlimit(10000000)

    input = sys.stdin.readline

    
    

    

    import os
    import math, itertools, operator
    from math import factorial as fact
    from operator import itemgetter, attrgetter
    from itertools import permutations, combinations
    from functools import reduce, lru_cache
    
    
    from fractions import gcd
    from fractions import Fraction as Frac

    inf = float('inf')

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

    def perm(a, b):
        import scipy.special
        return scipy.special.perm(a, b, exact = True)

    def comb(a, b):
        import scipy.special
        return scipy.special.comb(a, b, exact = True)

    def dfact(n):
        import scipy.special
        return scipy.special.factorial2(n, exact = True)

    def prod(l):
        return reduce(operator.mul, l)

    def input_ints(func = input, sep = None, conv = int):
        return list(map(conv, func().split(sep = sep)))

    if os.environ.get('GOROOT') is None:
        def dprint(*args, **kwargs):
            kwargs['file'] = sys.stderr
            import inspect
            frame = inspect.currentframe().f_back
            print('[' + os.path.basename(frame.f_code.co_filename)
                    + ':' + str(frame.f_lineno) + ']', *args, **kwargs)
    else:
        def dprint(*args, **kwargs):
            pass


    


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

    D.sort()
    p1 = D[N // 2 - 1]
    p2 = D[N // 2]
    dprint(D, p1, p2)
    print(p2 - p1)


if __name__ == '__main__':
    main()

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

sorted_d = sorted(d)

half = N // 2 - 1

pre_half = sorted_d[half]
rea_half = sorted_d[half + 1]

print(rea_half - pre_half)

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):
def main():
    N = int(input())
    D = list(map(int, input().split()))
    D.sort()
    ans = D[N//2] - D[N//2-1]
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import random
import collections
import math
import itertools
import bisect

def real_main():
    n = read_int()
    nums = read_int_array()
    nums.sort()
    m1, m2 = n // 2 - 1, n // 2
    if nums[m1] == nums[m2]:
        print(0)
    else:
        print(nums[m2] - nums[m1])


def solve():
    pass


def main():
    if False and 'PYCHARM_HOSTED' in os.environ:
        main_pycharm()
    else:
        real_main()


from copy import deepcopy
def main_pycharm():
    solution = solve

    test_inputs = None
    test_outputs = None
    judge = None
    slow_solution = None
    if solution is not None:
        if test_outputs is not None:
            test_with_answers(solution, test_inputs, test_outputs)
        if judge is not None:
            test_with_judge(solution, test_inputs, judge)
        if slow_solution is not None:
            test_with_slow_solution(solution, test_inputs, slow_solution)


def test_with_answers(solution, inputs, answers):
    total, wrong = 0, 0
    for args, test_ans in zip(inputs, answers):
        ans = solution(*deepcopy(args))
        if ans != test_ans:
            print('WRONG! ans=%s, test_ans=%s, args=%s' % (ans, test_ans, args))
            wrong += 1
        else:
            print('GOOD')
        total += 1
    print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))


def test_with_judge(solution, inputs_gen, judge):
    total, wrong = 0, 0
    for args in inputs_gen:
        ans = solution(*deepcopy(args))
        if not judge(deepcopy(ans), *deepcopy(args)):
            print('WRONG! ans=%s, args=%s' % (ans, args))
            wrong += 1
        total += 1
    print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))


def test_with_slow_solution(solution, inputs_gen, solution_slow):
    total, wrong = 0, 0
    for args in inputs_gen:
        ans = solution(*deepcopy(args))
        slow = solution_slow(*deepcopy(args))
        if ans != slow:
            print('WRONG! ans=%s, slow=%s, args=%s' % (ans, slow, args))
            wrong += 1
        total += 1
    print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))

def generate_nums(n, min, max, check_if_good=None):
    while True:
        nums = [random.randint(min, max) for _ in range(n)]
        if check_if_good is None or check_if_good(nums):
            return nums



def mergesort(A, key=lambda x: x, reverse=False):
    C = A
    A = list(range(len(A)))
    B = list(A)

    n = len(A)
    for i in range(0, n - 1, 2):
        if key(C[A[i]]) > key(C[A[i ^ 1]]):
            A[i], A[i ^ 1] = A[i ^ 1], A[i]

    width = 2
    while width < n:
        for i in range(0, n, 2 * width):
            R1, R2 = min(i + width, n), min(i + 2 * width, n)
            j, k = R1, i
            while i < R1 and j < R2:
                if key(C[A[i]]) > key(C[A[j]]):
                    B[k] = A[j]
                    j += 1
                else:
                    B[k] = A[i]
                    i += 1
                k += 1
            while i < R1:
                B[k] = A[i]
                k += 1
                i += 1
            while k < R2:
                B[k] = A[k]
                k += 1
        A, B = B, A
        width *= 2

    if reverse:
        A.reverse()
    return A

def mergesort_simple(A, reverse=False):
    C = A
    A = list(range(len(A)))
    B = list(A)

    n = len(A)
    for i in range(0, n - 1, 2):
        if C[A[i]] > C[A[i ^ 1]]:
            A[i], A[i ^ 1] = A[i ^ 1], A[i]

    width = 2
    while width < n:
        for i in range(0, n, 2 * width):
            R1, R2 = min(i + width, n), min(i + 2 * width, n)
            j, k = R1, i
            while i < R1 and j < R2:
                if C[A[i]] > C[A[j]]:
                    B[k] = A[j]
                    j += 1
                else:
                    B[k] = A[i]
                    i += 1
                k += 1
            while i < R1:
                B[k] = A[i]
                k += 1
                i += 1
            while k < R2:
                B[k] = A[k]
                k += 1
        A, B = B, A
        width *= 2

    if reverse:
        A.reverse()
    return A




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

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


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        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")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

def read():
    return input()

def read_int():
    return int(input())

def read_array(sep=None, maxsplit=-1):
    return input().split(sep, maxsplit)

def read_int_array():
    return [int(a) for a in read_array()]



if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = [int(a) for a in input().split()]

if N % 2 == 1:
    print(0)
else:
    X = [0] * 100100
    for i in range(N):
        X[A[i]] += 1
    Y = [0] * 100101
    for i in range(len(X)):
        Y[i+1] = Y[i] + X[i]
    ans = 0
    for i in range(len(Y)):
        if Y[i] == N//2:
            ans += 1
    print(ans)

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

Solution (Python):


from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

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

Solution (Python):











import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    D = LI()
    D.sort()
    print(D[N//2] - D[N//2 -1])
if __name__ == '__main__':
    main()

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

Solution (Python):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

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

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N = int(sys.stdin.readline())
D = list(map(int, sys.stdin.readline().split()))

D.sort()

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

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

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

Solution (Python):




def main():
    from sys import stdin

    input = stdin.readline
    N = int(input())
    D = list(map(int,input().split()))
    D.sort()
    lower = D[N//2-1]
    upper = D[N//2]
    print(upper-lower)
if __name__ == '__main__':
    main()

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

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

Solution (Python):

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    d = list(map(int, input().split()))
    d.sort()
    m1 = d[n//2 - 1]
    m2 = d[n//2]
    
    if m1 == m2:
        print(0)
    else:
        ans = m2 - m1
        print(ans)

if __name__ == '__main__':
    main()

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

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

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


if __name__ == '__main__':
  main()

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
D = sorted(nl())

before = D[N // 2 -1]
after = D[N // 2]

print(after - before)

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

Solution (Python):
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
l=arr[n//2-1]
r=arr[n//2]
ans=r-l
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())
ds = list(map(int, input().split()))
ds = sorted(ds)
print(ds[N//2]-ds[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 = [int(x) for x in input().split()]

d.sort()

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

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, d: "List[int]"):
    d.sort()
    print(d[N//2]-d[N//2-1])

    return


def main():

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


if __name__ == '__main__':
    main()

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

Solution (Python):
import bisect
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(sorted(map(int, input().split())))

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):
A = [0]*100010
N = int(input())
for i in input().split(" "):
	A[int(i)] += 1
total = 0
ans = 0
isOver = False
for i in range(100010):
	total += A[i]
	if total == N/2:
		ans += 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, = map(int, input().split())
D.sort()
*P, = D[:N//2]
*Q, = D[N//2:]
print(Q[0] - P[-1])