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
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n = load()
d = load_list()

l = 1
r = int(math.pow(10, 5))

def check(k):
    abc = []
    arc = []
    for e in d:
        if e >= k:
            arc.append(e)
        else:
            abc.append(e)
    if len(arc) > len(abc):
        return 1
    elif len(abc) > len(arc):
        return -1
    else:
        return 0


ans1 = -1
while l < r:
    mid = int((l + r) / 2)
    c = check(mid)
    if c == 0:
        ans1 = mid
        break
    elif c == 1:
        l = mid + 1
    elif c == -1:
        r = mid - 1
    

if ans1 == -1:
    print(0)
    exit()
tmp = ans1
cnt = 1


l = ans1
r = int(math.pow(10, 5))

ans2 = ans1
while l <= r:
    mid = int((l + r) / 2)
    c1 = check(mid)
    c2 = check(mid+1)
    if c1 != 0:
        r = mid -1
    elif c1 == 0 and c2 == 0:
        l = mid + 1
    elif c1 == 0 and c2 != 0:
        ans2 = mid
        break

l = 1
r = ans1

ans3 = ans1
while l <= r:
    mid = int((l + r) / 2)
    c1 = check(mid)
    c2 = check(mid-1)
    if c1 != 0:
        l = mid + 1
    elif c1 == 0 and c2 == 0:
        r = mid - 1
    elif c1 == 0 and c2 != 0:
        ans3 = mid
        break

cnt += (ans2 - ans1)
cnt += (ans1 - ans3)


print(cnt)

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

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

Solution (Python):
from collections import Counter
n = int(input())
d = list(map(int, input().split()))
cnt = Counter(d)
cnt = sorted(cnt.items(), key=lambda x:x[0])
val = 0
for idx, (i, v) in enumerate(cnt):
    val += v
    if val == n // 2:
        print(cnt[idx+1][0] - cnt[idx][0])
        exit()
    elif val > n // 2:
        print(0)
        exit()
    else:
        continue

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

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

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

k = 0 

x = (n // 2) -1 

start = d[x] + 1
end = d[x+1] + 1

result = list(range(start,end))
print(len(result))

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

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

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()))
freq=[0]*(10**5+3)
for i in d:
    freq[i]+=1
ans=0
su=0
for i in range(1,10**5+1):
    su+=freq[i]
    if 2*su==n:
        ans+=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()
a = d[-1 + n//2]
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 = sorted(list(map(int, input().split())))

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

Solution (Python):

import sys


def solve(N: int, d: "List[int]"):
    sd = sorted(d)
    print(sd[N//2] - sd[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())
dis = list(map(int, input().split()))
dis = sorted(dis)
h = int(n/2)
m = dis[h] - dis[h-1]
print(m)

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

main()

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

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

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

a=y[len(y)//2]
b=y[(len(y)//2)-1]

if a==b:
	print(0)
else :
	print(a-b)

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

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

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

M = N//2

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

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

lim = len(d) // 2 - 1
res = sorted(d)

print(res[lim+1] - res[lim])

Solution (Python):

n =int(input())
d = list(map(int,input().split()))
d.sort()
L = int(len(d) / 2) - 1
R = L + 1
ans = []

for i in range(d[L]+1,d[R]+1):
    ans.append(i)
print(len(ans))

Solution (Python):
import bisect

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

if N % 2 == 1:
    print(0)
else:
    half = N // 2
    cnt = 0
    for k in range(0, 100005):
        if bisect.bisect_left(D, k) == half:
            cnt += 1
    print(cnt)

Solution (Python):












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

breakpoint1 = len(arrA)//2 -1
breakpoint2 = breakpoint1+1

ans = arrA[breakpoint2] - arrA[breakpoint1]
print(ans)

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

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

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

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

d = sorted(d)

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

print ans

Solution (Python):
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd



import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


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

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from heapq import heappush, heappop


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

if __name__ == '__main__':
    main()

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

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

d_sorted = sorted(d_list)

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

Solution (Python):
import bisect







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

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

resolve()

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

a = sorted(l)
print(a[n // 2] - a[n // 2 - 1])

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

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

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

Solution (Python):

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

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

Solution (Python):
import sys
import os


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

    N = int(sys.stdin.buffer.readline().rstrip())
    D = list(map(int, sys.stdin.buffer.readline().split()))
    D.sort()
    print(D[N//2]-D[N//2-1])


if __name__ == '__main__':
    main()

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()
d = na()
d.sort()
l = d[n//2-1]
r = d[n//2]
if l != r:
    print(r-(l+1)+1)
else:
    print(0)

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

Solution (Python):
N = input()
d = list(map(int, input().split()))
d.sort()
n = int(len(d) / 2)
d_1 = d[:n]
d_2 = d[n:]

if d_1[n - 1] == d_2[0]:
    print(0)
else:
    print(d_2[0] - d_1[n - 1])

Solution (Python):

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

if lend % 2 == 1:
    ans = 0
else:
    lend2 = lend//2
    a1 = d[lend2-1]
    a2 = d[lend2]
    ans = a2 - a1

print(ans)

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

print(solve())

Solution (Python):
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

N = ni()
D = nl()

D.sort()

s1 = D[N//2 -1 ]
s2 = D[N//2]

print(s2 - s1)

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

d.sort()

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

Solution (Python):
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = lr()
D.sort()
border = N // 2 -1
left = D[border]
right = D[border+1]
answer = right - left
print(answer)

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

D1 = D[int(N / 2) -1]
D2 = D[int(N / 2)]

count = 0

for i in range(D1, D2, 1):
	count+=1

print(count)

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

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

half = d[N // 2 - 1]
nxt = d[N // 2]

if nxt == half:
    print(0)
else:
    print(nxt - (half + 1) + 1)

Solution (Python):

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

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

Solution (Python):
def main(n, d):
    d.sort()

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


if __name__ == "__main__":
    n = int(input())
    d = list(map(int, input().split()))

    main(n, d)

Solution (Python):
N = int(input())
if N%2!=0:
    print(0)
else:
    List = sorted([int(i) for i in input().split(" ")])
    n = List[N//2-1]
    m = List[N//2]
    print(m-n)

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):
N=int(input())
d=list(map(int,input().split()))
d=sorted(d)
print(d[int(N/2)]-d[int((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 = [int(c) for c in input().split()]
e = sorted(d)
mid = n//2
print(e[mid]-e[mid-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())
d = list(map(int,input().split()))


d = sorted(d)
count = 0
if len(d)%2 == 0:
	if d[len(d)//2-1] == d[len(d)//2]:
		print(0)
	else:
		temp = d[len(d)//2]- d[len(d)//2-1]
		count += temp
		print(count)
else:
	print(0)

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

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

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

list_score.sort()

ans = 0

if n%2 == 0:
    ans = list_score[n//2] - list_score[n//2 - 1]

print(ans)

Solution (Python):
n, *d = map(int, open(0).read().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 = [int(i) for i in input().strip().split()]

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

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

Solution (Python):



N = int(input())
d_nums = map(int, input().split())


d_nums = sorted(d_nums)
d_len = len(d_nums)
median_1 = d_nums[d_len//2-1]
median_2 = d_nums[d_len//2]


if d_len%2==0:
    ans = median_2 - median_1
    print(ans)
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):
n = int(input())
d = list(map(int,input().split()))
arc = []
abc = []
cnt = 0
d.sort()
pivot = n//2
k = d[pivot]
for i in range(n):
    if d[i] >= k:
        arc.append(d[i])
    elif d[i] < k:
        abc.append(d[i])
if len(arc) == len(abc):
    cnt = d[pivot] - d[pivot-1]
print(cnt)

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

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

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

    print(ans)

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


if __name__ == "__main__":
    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(i) for i in input().split()] 

d.sort()
ans = d[n // 2] - d[n // 2 - 1]
print(max(ans, 0))

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

d.sort()

a = d[N//2 - 1]
b = d[N//2]


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

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

if N&1:
    print(0)
    exit()
D.sort()
print(D[N//2]-D[N//2-1])

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

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

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

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 collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = sorted(inpl())
print(max(0, a[n//2]-a[n//2-1]))

Solution (Python):
import sys, re, os
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 STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

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

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

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

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

left = n//2 -1
right = n//2

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

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


B = N // 2 -1

ans = D[B+1] -D[B]
print(ans)

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

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

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

s, t = N//2-1, N//2

ans = d[t] - d[s]
print(ans)

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

Solution (Python):

N = int(input())

data = sorted(list(map(int, input().split())))
median = int(N / 2)

print(data[median] - data[median - 1])

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

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

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
d = [int(x) for x in input().split()]

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

Solution (Python):
from sys import stdin

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

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

if a == b:
    print(0)
else:
    c = [i for i in range(a+1, b+1)]
    print(len(c))

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

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

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

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

for i in range(d[n//2 -1] + 1,d[n//2] + 1):
    ans.append(i)
 
        
print(len(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_list = [int(s) for s in input().split()]

d_list = sorted(d_list)

if len(d_list) % 2 != 0:
  print(0)
  sys.exit()
  
upper = len(d_list) // 2
lower = upper - 1

print(d_list[upper] - d_list[lower])

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([int(i) for i in input().split()])
idx_p = int(len(d) / 2) - 1
idx_a = int(len(d) / 2)
if d[idx_p] != d[idx_a]:
	print (d[idx_a] - d[idx_p])
else:
	print (0)

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

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

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

Solution (Python):
n = int(input())
D = [int(s) for s in input().split(' ')]
D.sort()
lower = D[n//2 - 1]
upper = D[n//2]
ret = upper - lower
print(ret)

Solution (Python):
n = int(input())
l = list(map(int, input().split(' ')))
d = {}  
for i in l:
    d[i] = d.get(i, 0) + 1
sums = 0
ans = 0
sorted_kv = sorted(d.items())
for i in range(len(sorted_kv)):
    key, val = sorted_kv[i]
    sums += val
    if sums == n // 2:
        ans = sorted_kv[i+1][0] - key
        break
print(ans)

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

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

Solution (Python):





import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    d = list(map(int,ipti().split()))
    d.sort()
    sita = d[len(d)//2 - 1]
    ue = d[len(d)//2]

    print(ue-sita)

if __name__ == '__main__':
    main()

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

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

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

d_ls.sort()
small = d_ls[len(d_ls)//2-1]
big = d_ls[len(d_ls)//2]
print(big - small)

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

lst2 = sorted(lst)
print(lst2[n//2]-lst2[n//2-1])

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

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

    
    
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right

lst2 = quick_sort(lst)
print(lst2[n//2]-lst2[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()))

p = sorted(d)
x,y = p[len(p)//2-1], p[len(p)//2]


print(y - x)

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 = 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(max(0, d[n//2] - d[n//2 - 1]))

Solution (Python):
from collections import Counter

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

minD = min(d)
maxD = max(d)
c = Counter(d)

abc = 0
arc = n
ans = 0

for i in range(minD, maxD+1):
    abc += c[i-1]
    arc -= c[i-1]
    
    if abc == arc:
        ans += 1

print(ans)

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

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

Solution (Python):
n = int(input())
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()))
ans = 0
d.sort()
k = d[int(n/2)]
while k > d[int(n/2)-1]:
   k -= 1
   ans += 1
print(ans)

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

D.sort()

prob = N // 2

print(D[prob] - D[prob-1])

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

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

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

Solution (Python):



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

if __name__=='__main__':
  main()

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

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

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

d.sort()
div = len(d)//2 
if d[div-1] == d[div]:
    ans = 0
else:
    ans = d[div] - d[div-1]
print(ans)

Solution (Python):
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *d = map(int, read().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()
if n%2==0:
    print(d[n//2]-d[n//2-1])
else:
    print(0)

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

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

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

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

print(b - a)

Solution (Python):
n = int(input())
m = list(map(int, input().split()))
ms = sorted(m)
m_mid = ms[len(ms) // 2]
m_1mid = ms[len(ms) // 2 - 1]
if m_mid == m_1mid:
    print(0)
else:
    print(m_mid - m_1mid)

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

m = int(len(d) / 2)
if d[m-1] == d[m]:
    print(0)
else:
    ans = list(range(d[m-1] + 1, d[m] + 1))
    print(len(ans))

Solution (Python):
n, *d = map(int, open(0).read().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())
A = list(map(int , input().split()))
B = sorted(A)
nagasa = int(len(B)/2)
if B[nagasa] == B[nagasa-1]:
    ans = 0
else:
    ans = B[nagasa] - B[nagasa-1]
print(ans)

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

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

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

ans=1
dl.sort()
if n%2==0:
    mid=n//2
    ans=dl[mid]-dl[mid-1]
print(ans)

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

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

t.sort()

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

Solution (Python):
n = int(input())//2
a = list(map(int, input().split()))
a.sort()
print(a[n]-a[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):
def main():
  import sys
  input=sys.stdin.read
  n,*d=map(int,input().split())
  e=tuple(sorted(d))
  l=len(d)
  s=n//2
  if e[s-1]==e[s]:
    print(0)
  else:
    print(e[s]-e[s-1])
      
if __name__=="__main__":
  main()

Solution (Python):
def main():
  
  n,*d=map(int,open(0).read().split())
  d=tuple(sorted(d))
  l=len(d)
  s=n//2
  if d[s-1]==d[s]:
    print(0)
  else:
    print(d[s]-d[s-1])
      
if __name__=="__main__":
  main()