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

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data)
ind_mid = N // 2
ans = 0
if data[ind_mid] == data[ind_mid-1]:
    ans = 0
else:
    ans = data[ind_mid] - data[ind_mid-1]
print(ans)

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

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

d.sort()
c = len(d)

dl = d[c // 2 - 1]
dr = d[c // 2]

ans = dr - dl
print(ans)

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

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

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):
import numpy as np
import copy


def main():
    
    
    
    
    
    
    
    

    N = int(input())
    ds = list(map(int, input().split()))
    ds = np.array(ds, dtype=np.int)

    ds = np.sort(ds)

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


if __name__ == '__main__':
    main()

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

Solution (Python):

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

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

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

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

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

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

Solution (Python):
import math
N = int(input())
d = [int(i) for i in input().split()]
d.sort()
middle = (N-1)/2
left = d[math.floor(middle)]
right = d[math.ceil(middle)]
print(right-left)

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

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

half = N//2

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

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

if N%2==0 and D[N//2]!=D[N//2-1]:
    K=D[N//2]-D[N//2-1]

print(K)

Solution (Python):

n = int(input())
arr = [int(i) for i in input().split(" ")]
arr.sort()
middle = int(n / 2)
l = arr[middle-1]
h = arr[middle]
ans = h - l 
print(ans)

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

count = 0

d.sort()
avr = int(n/2)
count = d[avr] -d[avr -1] 

print(count)

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

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

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

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

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

Solution (Python):






N = int(input())
d = list(map(int,input().split()))
d.sort()
l = int(0.5*N -1)
r = int(0.5*N)

ans = int(d[r] - d[l])
                        
print(ans)

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

d0 = d[int(n/2)-1]
d1 = d[int(n/2)]

print(d1 - d0)

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

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

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

    print(b-a)


main()

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

d.sort()
k=int(N/2)
a=d[k]-d[k-1]
print(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())
listd = [int(i) for i in input().split()]

listd.sort()
s,l = listd[int(n/2)-1],listd[int(n/2)]
print(l-s)

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

d.sort()
dk = d[N//2-1:N//2+1]

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

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

if __name__ == "__main__":
    resolve()

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

m=n//2
l=line[m]-line[m-1]
print(l)

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

list.sort()

B = int((n/2)-1)
A = int((n/2))

if list[B] == list[A]:
  print("0")
else:
  count = list[A] - list[B] 
  print(count)

Solution (Python):
import statistics

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

count = statistics.median_high(D) - statistics.median_low(D)

print(count)

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()
print(d[len(d)//2] - d[len(d)//2 - 1])

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

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

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

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

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

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

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

D.sort()

print(str(D[n//2] - D[(n//2)-1]))

Solution (Python):


import sys
sys.setrecursionlimit(1000000)
from collections import deque

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

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

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

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

print(b-a)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    s = S()
    b = list(set(s))
    a = len(list(set(s)))
    if a == 2 and s.count(b[0]) == s.count(b[1]) == 2:
        print("Yes")
    else:
        print("No")
    return


def B():
    n = II()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
            ans += 1
    print(ans)
    return


def C():
    n = II()
    d = LI()
    d.sort()
    ans = 0
    for i in range(10**5+1):
        if n // 2 == bisect_left(d, i):
            ans += 1
    print(ans)
    return


def combination_mod(n, k, mod):
    
    

    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = factorial(n) % mod
    b = factorial(k) % mod
    c = factorial(n - k) % mod
    return (a * power_func(b, mod - 2, mod) * power_func(c, mod - 2, mod)) % mod
    
def power_func(a, b, mod):
    
    

    if b == 0: return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, mod)
        return d * d % mod
    if b % 2 == 1:
        return (a * power_func(a, b - 1, mod)) % mod


def D():
    n, k = LI()
    ans = 0
    for i in range(1,k+1):
        a = combination_mod(n - k + 1, i, mod)
        b = combination_mod(k - 1, i - 1, mod)
        print(a*b)
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    C()

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

Solution (Python):
import itertools


def solve(n, ds):
    cs = sorted(ds)
    cur_num_items = 0
    k_lb = None
    k_ub = None
    table = [(k, len(tuple(g))) for k, g in itertools.groupby(cs)]
    for k, m in table:
        cur_num_items += m
        if k_lb is not None:
            k_ub = k
            break
        elif cur_num_items == n // 2:
            k_lb = k + 1
        elif cur_num_items > n // 2:
            return 0
    res = k_ub - k_lb + 1
    return res


def main():
    n = int(input())
    ds = [int(d) for d in input().split()]
    res = solve(n, ds)
    print(res)


if __name__ == "__main__":
    main()

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

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

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

c=int(N/2)
a=s[c-1]
b=s[c]
print(b-a)

Solution (Python):
from bisect import bisect_left, bisect_right

def solve(N, D):
    D = sorted(D)
    m = D[N//2]
    l = bisect_left(D, m)  
    r = bisect_right(D, m) 
    
    
    if l == N-l:
        return D[l] - D[l-1]
    else:
        return 0



N = int(input())
D = [int(x) for x in input().split()]
print(solve(N, D))

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

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

Solution (Python):
n = int(input())
d = sorted([int(i) for i in input().split()])
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 fractions


inp_ = int(input())

co =0
inp = [int(i) for i in input().split()]

inp.sort()

f = int(inp_/2) -1

ff = inp[f]
ee = inp[f+1]

dd = ee-ff

print(dd)

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

Solution (Python):
import sys

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

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

Solution (Python):

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

Solution (Python):
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True 
def ddprint(x):
  if DBG:
    print(x)

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

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

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

l = sorted(l)


print(l[int(n/2)] - l[int(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())
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()

i = n//2

arc = d[i]
abc = d[i-1]

print(arc - abc)

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

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

center = N // 2
d.sort()
left = d[center - 1]
right = d[center]

print(right - left) if left != right else print(0)

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

Solution (Python):



import sys
def p(*a):
  s=" ".join(map(str,a))
  
  sys.stderr.write(s+"\n")


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

n=N//2

a=d[:n]
b=d[n:]

p(d)
p(a)
p(b)

ans=max(0, b[0]-a[-1])

print(ans)

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

LEN = int(len(D))
DV = int(int(LEN)/2)


HALF_B = D[DV-1]
HALF_F = D[DV]
DIF = HALF_F - HALF_B

print(DIF)

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

d = sorted(d)

if d[len(d)//2-1] == d[len(d)//2]:
    print(0)
else:
    dif =  d[len(d)//2] - d[len(d)//2-1]
    print(dif)

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()))
dn = sorted(d)
ea = dn[N//2-1]
eb = dn[N//2]

print(eb-ea)

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

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

numlist.sort()

num1 = N // 2
num2 = N // 2 + 1


if numlist[num2-1] == numlist[num1-1]:
    print(0)
else:
    print(numlist[num2-1]-numlist[num1-1])

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

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

ds = sorted(ds)

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

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

cnt = 0
lend = len(d)
d = sorted(d)
left = d[(lend//2)-1]
right = d[(lend//2)]

print(right-left)

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

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

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

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

r = D[n // 2]
l = D[n // 2 - 1]

if l == r:
    print(0)
    exit()

print(r - l)

Solution (Python):

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

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

S.sort()

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

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

Solution (Python):
def merge_sort(arr):
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    
    left = arr[:mid]
    right = arr[mid:]

    
    left = merge_sort(left)
    right = merge_sort(right)

    
    return merge(left, right)


def merge(left, right):
    merged = []
    l_i, r_i = 0, 0

    
    while l_i < len(left) and r_i < len(right):
        
        if left[l_i] <= right[r_i]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1

    
    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged

if __name__ == "__main__":
    n = int(input())
    d = list(map(int, input().split()))
    d = merge_sort(d)
    l = len(d)
    a = d[l//2-1]
    b = d[l//2]
    print(b-a)

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

Solution (Python):
def resolve():

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

    d = sorted(d)

    index_left = int((len(d) / 2) -1)
    index_right = int((len(d) / 2))

    num_left = d[index_left]
    num_right = d[index_right]

    print(num_right - num_left)
    
resolve()

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

D.sort()
between = D[int(N/2)] - D[int((N/2)-1)]

print(between)

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

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

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

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

sorted_d_list = sorted(d_list)
d_abc = sorted_d_list[n//2 - 1]
d_arc = sorted_d_list[n//2]

print (d_arc - d_abc)

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys

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

def LI(): return list(map(int, sys.stdin.readline().split()))

import numpy as np
N = int(input())
d = LI()
d.sort()
cnt = 0
ans = d[N//2]-d[N//2-1]
print(ans)

Solution (Python):
import sys
from fractions import gcd
import bisect
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    ps = LI()
    if n % 2 != 0:
        print(0)
        return
    sr = sorted(ps)
    print(sr[n//2] - sr[n//2 - 1])





if __name__ == "__main__":
    main()

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
n = int(input())
if n % 2 == 1:
    print(0)
    sys.exit()
half = int(n / 2)
d = list(map(int, input().split()))
d.sort()
print(d[half] - d[half - 1])

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

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

Solution (Python):

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

d.sort()

half = n // 2
max_abc = d[half - 1]
min_agc = d[half]

if max_abc == min_agc:
    print(0)
else:
    print(min_agc - max_abc)

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


li.sort()
p=li[-1+n//2]
q=li[n//2]

print(q-p)

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

Solution (Python):
import sys

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

if N%2==1:
	print 0
else:
	p1=N/2-1
	p2=N/2
	if D[p1]==D[p2]:
		print 0
	else:
		print D[p2]-D[p1]

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

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

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

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

print(K)

Solution (Python):


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

dn.sort()

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

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

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

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

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

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

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

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    D = list(map(int, input().split()))
    D.sort()

    left, right = D[N//2 - 1], D[N//2]
    return right - left


if __name__ == '__main__':
    print(main())

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

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


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

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




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



if __name__ == "__main__":
    main()

Solution (Python):
import sys

input = sys.stdin.readline

N = int(input().strip())
ds = list(map(int, input().strip().split(' ')))

median = (N - 1) // 2
ds.sort()
num = ds[median + 1] - ds[median]
print(num)

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

d.sort()
l = len(d)//2 - 1
print(d[l+1] - d[l])

Solution (Python):

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

print(ans)

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

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

Solution (Python):
a=input()
a=int(a)
b=input().split()
b=[int(i) for i in b]
ans=0
b.sort()
if a%2==1:
  print(0)
elif b[a//2]==b[a//2-1]:
  print(0)
else:
  print(b[a//2]-b[a//2-1])

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

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

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

if __name__ == '__main__':
    main()

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

Solution (Python):




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


d.sort()


med1 = d[int(n / 2) - 1]
med2 = d[int(n / 2)]

ans = med2 - med1


print(ans)

Solution (Python):

import sys


def solve(N: int, d: "List[int]"):
    if N % 2 != 0: return 0

    d = sorted(d)
    midl = d[(1 + N) // 2 - 1]
    midr = d[(1 + N) // 2]

    if midl == midr: return 0

    return midr - midl



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) ]  
    print(solve(N, d))

if __name__ == '__main__':
    main()

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

dn.sort()

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

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

d.sort()

ni = n // 2

k = d[ni] - d[ni-1]

print(k)

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


N = int(input())
D = inpl()
D.sort()

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

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

print(base)

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

Solution (Python):

def read_input():
    n = int(input())
    dlist = list(map(int, input().split()))
    return n, dlist


def submit():
    n, dlist = read_input()
    dlist.sort()

    mid = n // 2  
    min_arc_idx = mid
    max_abc_idx = mid - 1

    print(dlist[min_arc_idx] - dlist[max_abc_idx])
    return


if __name__ == '__main__':
    submit()

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

d.sort()
mid = N // 2
K = d[mid-1]
K_1 = d[mid]

if K == K_1:
    print(0)
    exit()

print(K_1 - K)

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

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

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

d.sort(reverse = False)

tmp = int(N/2)

if d[tmp-1] != d[tmp]:
    print(d[tmp] - d[tmp-1])

else:
    print(0)

Solution (Python):

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

ans = 0

d.sort()



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

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

d.sort()
l = n//2

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

Solution (Python):
import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial

sys.setrecursionlimit(1000000)










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

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

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

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

cnt = Counter(D)
lst = []
for key in sorted(cnt.keys()):
    lst.append([key, cnt[key]])

ans = 0
tmp = 0
for i, kv in enumerate(lst):
    key, value = kv
    tmp += value
    if tmp == N - tmp:
        if i + 1 < len(lst):
            ans = lst[i+1][0] - key
            break
        else:
            break
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())
L=sorted(list(map(int,input().split())))
print(L[len(L)//2]-L[len(L)//2-1])

Solution (Python):

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

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

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)
def solve():
    N = int(input())
    d_list = list(map(int, input().split()))
    d_list.sort()

    dprint(d_list)


    if N % 2 != 0:
        print(0)
        return

    cnt = 0

    left = d_list[N//2-1]
    right = d_list[N//2]
    dprint(left, right)
    print(right-left)

solve()