AtCoder Beginner Contest 132 - Divide the Problems

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-----
6
9 1 4 4 6 7

-----Sample Output-----
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.

Difficulty: EASY

Starter code:

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


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


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


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


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


N = int(input())
d = list(map(int, input().split()))
d = sorted(d)
if N % 2 != 0:
	print(0)
else:
	x = N // 2
	ans = d[x] - d[x - 1]
	print(ans)


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


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


N = int(input())
d = sorted([int(c) for c in input().split()])
print(d[N // 2] - d[N // 2 - 1])


n = int(input())
dif = list(map(int, input().split()))
new_dif = list(sorted(dif))
if new_dif[n // 2 - 1] == new_dif[n // 2]:
	print(0)
else:
	print(new_dif[n // 2] - new_dif[n // 2 - 1])


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


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


n = int(input())
D = sorted([int(i) for i in input().split()])
print(D[n // 2] - D[n // 2 - 1])


N = int(input())
a = list(map(int, input().split()))
a.sort()
half = int(len(a) / 2)
if a[half - 1] == a[half]:
	print(0)
else:
	print(a[half] - a[half - 1])


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


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


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


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


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


def main():
	N = int(input())
	d = sorted(list(map(int, input().split())))
	ans = 0
	if d[N // 2] != d[N // 2 - 1]:
		ans = d[N // 2] - d[N // 2 - 1]
	print(ans)

def __starting_point():
	main()
__starting_point()


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


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


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


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


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


n = int(input())
d = [int(x) for x in input().split()]
d.sort()
print(d[n // 2] - d[n // 2 - 1])


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


N = int(input())
d = list(map(int, input().split()))
d = sorted(d)
mid = N // 2
s = d[mid - 1]
f = d[mid]
print(f - s)


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


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


(n, *dd) = map(int, open(0).read().split())
dd.sort()
print(dd[n // 2] - dd[n // 2 - 1])


N = int(input())
d = [int(x) for x in input().split()]
d.sort()
ans = d[N // 2] - d[N // 2 - 1]
print(ans)


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


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


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


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


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


(N, *A) = map(int, open(0).read().split())
A.sort()
ans = A[N // 2] - A[N // 2 - 1]
print(ans)


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


n = int(input())
l = [int(s) for s in input().split()]
cnt = 0
l.sort()
print(l[n // 2] - l[n // 2 - 1])


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


n = int(input())
d_l = list(map(int, input().split()))
d_l = sorted(d_l)
if len(d_l) % 2 != 0:
	print(0)
else:
	idx = int(len(d_l) / 2)
	abc = d_l[idx - 1]
	agc = d_l[idx]
	print(agc - abc)


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


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


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


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


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


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


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


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


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


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


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


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


N = int(input())
ls = list(map(int, input().split(' ')))
ls.sort()
first_half = ls[:N // 2]
second_half = ls[N // 2:]
if first_half[-1] == second_half[0]:
	print(0)
else:
	print(second_half[0] - first_half[-1])


n = int(input())
D = list(map(int, input().split()))
D.sort()
print(min(D[n // 2:]) - max(D[:n // 2]))


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


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


N = int(input())
D = list(map(int, input().split()))
D.sort()
A = list(range(D[int(N / 2) - 1] + 1, D[int(N / 2)] + 1))
print(len(A))


n = int(input())
dn = list(map(int, input().split()))
dn.sort()
a = dn[n // 2 - 1]
b = dn[n // 2]
cnt = 0
for i in range(a, b):
	cnt += 1
print(cnt)


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


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


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


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


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


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


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


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


import sys
input = sys.stdin.readline
n = int(input())
d = list(map(int, input().split()))
d.sort()
a = d[n // 2] - d[n // 2 - 1]
if a > 0:
	print(a)
else:
	print(0)


INT = lambda : int(input())
INTM = lambda : map(int, input().split())
STRM = lambda : map(str, input().split())
STR = lambda : str(input())
LIST = lambda : list(map(int, input().split()))
LISTS = lambda : list(map(str, input().split()))

def do():
	n = INT()
	A = LIST()
	A = sorted(A)
	print(A[n // 2] - A[n // 2 - 1])

def __starting_point():
	do()
__starting_point()


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


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


n = int(input())
dlist = list(map(int, input().split()))
dlist_sorted = sorted(dlist)
kiwa_upper = dlist_sorted[n // 2]
kiwa_low = dlist_sorted[n // 2 - 1]
if len(dlist_sorted[n // 2:]) != n // 2:
	print(0)
else:
	print(kiwa_upper - kiwa_low)


import sys
N = int(input())
d = list(map(int, input().split()))
K_cnt = 0
dsort = sorted(d)
d_left = dsort[int(N / 2) - 1]
d_right = dsort[int(N / 2)]
if d_left == d_right:
	print(0)
else:
	print(d_right - d_left)


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


a = int(input())
b = sorted(list(map(int, input().split())))
print(b[a // 2] - b[a // 2 - 1])


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


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


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


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


import math
import statistics
a = int(input())
f = list(map(int, input().split()))
f.sort()
tyu = statistics.median(f)
if f[len(f) // 2] == f[len(f) // 2 - 1]:
	print(0)
else:
	print(f[len(f) // 2] - f[len(f) // 2 - 1])


(n, *d) = map(int, open(0).read().split())
d.sort()
print(d[n // 2] - d[n // 2 - 1])


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


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


N = int(input())
d = [int(c) for c in input().split()]
d.sort()
print(d[int(N / 2)] - d[int(N / 2) - 1])


(n, *a) = map(int, open(0).read().split())
a.sort()
print(a[n // 2] - a[n // 2 - 1])


import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
input = sys.stdin.readline

def RD():
	return input().rstrip()

def F():
	return float(input().rstrip())

def I():
	return int(input().rstrip())

def MI():
	return map(int, input().split())

def MF():
	return map(float, input().split())

def LI():
	return list(map(int, input().split()))

def TI():
	return tuple(map(int, input().split()))

def LF():
	return list(map(float, input().split()))

def Init(H, W, num):
	return [[num for i in range(W)] for j in range(H)]

def main():
	N = I()
	L = LI()
	L.sort()
	n = N // 2
	l = L[n - 1]
	r = L[n]
	print(r - l)

def __starting_point():
	main()
__starting_point()


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


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


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


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


n = int(input())
d = [int(x) for x in input().split()]
d = sorted(d)
print(d[n // 2] - d[n // 2 - 1])


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


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


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


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


n = int(input())
h = n // 2
(*l,) = map(int, input().split())
l.sort()
print(l[h] - l[h - 1])


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


n = int(input())
(*a,) = sorted(map(int, input().split()))
m = len(a) // 2
print(a[m] - a[m - 1])


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


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


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

class Solution:

	def __init__(self, n, dn):
		self.n = n
		self.dn = dn

	def __reverse(self):
		self.dn.sort()
		return self.dn

	def answer(self):
		self.dn = self.__reverse()
		a = self.dn[self.n // 2 - 1]
		b = self.dn[self.n // 2]
		print(b - a)
conditions = Solution(n, dn)
conditions.answer()


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


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


N = int(input())
D = [int(x) for x in input().split()]
D.sort()
print(D[N // 2] - D[N // 2 - 1])


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


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


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


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


input_num = int(input())
input_line = input().split()
input_line = [int(s) for s in input_line]
input_line.sort()
if input_line[int(len(input_line) / 2 - 1)] == input_line[int(len(input_line) / 2)]:
	print(0)
else:
	print(input_line[int(len(input_line) / 2)] - input_line[int(len(input_line) / 2) - 1])


m = int(input()) // 2
l = sorted(list(map(int, input().split())))
print(l[m] - l[m - 1])


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


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


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


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


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


from bisect import bisect_left
n = int(input())
d = list(map(int, input().split()))
d = sorted(d)
ans = 0
for i in range(1, 10 ** 5 + 1):
	p = bisect_left(d, i)
	ans += 1 if p == n - p else 0
print(ans)


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

def __starting_point():
	main()
__starting_point()


N = int(input())
ls = [int(s) for s in input().split()]
ls.sort()
print(ls[N // 2] - ls[N // 2 - 1])


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


n = int(input())
d = list(map(int, input().split()))
d = sorted(d, reverse=True)
cent_index = int(n / 2) - 1
print(d[cent_index] - d[cent_index + 1])


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


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


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


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


input()
a = sorted(list(map(int, input().split())))
print(a[len(a) // 2] - a[len(a) // 2 - 1])


n = int(input()) // 2
a = sorted((int(x) for x in input().split()))
print(a[n] - a[n - 1])


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


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


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
print(a[n // 2] - a[n // 2 - 1])


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


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


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


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


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


N = int(input())
D = sorted([int(i) for i in input().split()])
print(D[N // 2] - D[N // 2 - 1])


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


n = int(input())
d = [int(x.strip()) for x in input().split()]
d_sorted = sorted(d)
m = int(n / 2)
abc_fin = d_sorted[m - 1]
arc_start = d_sorted[m]
if abc_fin == arc_start:
	ans = 0
else:
	ans = arc_start - abc_fin
print(ans)


import sys
input = sys.stdin.readline

def main():
	exams = []
	sorted_exams = []
	n = int(input())
	exams = list(map(int, input().split()))
	sorted_exams = sorted(exams)
	half = n // 2
	start = sorted_exams[half - 1]
	end = sorted_exams[half]
	print(end - start)

def __starting_point():
	main()
__starting_point()


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


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


n = int(input())
d = list(map(int, input().split()))
d.sort()
ans = 0
for i in range(1, 10 ** 5 + 1):
	if d[n // 2 - 1] < i and d[n // 2] >= i:
		ans += 1
print(ans)


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


(N, *D) = map(int, open(0).read().split())
D.sort()
n = N // 2
print(D[n] - D[n - 1])


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


n = int(input())
d = [int(a) for a in input().split()]
d.sort()
print(d[n // 2] - d[n // 2 - 1])


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


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


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


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


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


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


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


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


import math
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions import gcd
n = int(input())
d = list(map(int, input().split()))
d.sort()
if d[n // 2] - d[n // 2 - 1] == 0:
	print(0)
else:
	print(d[n // 2] - d[n // 2 - 1])


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


N = int(input())
d = list(map(int, input().split()))
p = [0] * N
for i in range(N):
	p[i] = (d[i], i)
p.sort()
result = abs(p[N // 2][0] - p[N // 2 - 1][0])
print(result)


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


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


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


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


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


n = int(input())
l = sorted([int(u) for u in input().split()])
print(l[n // 2] - l[n // 2 - 1])


n = int(input())
D = list(map(int, input().split()))
D.sort()
d = {}
c = 0
for i in range(n):
	d[D[i]] = d.get(D[i], 0) + 1
a1 = -1
a2 = -1
for i in d:
	c += d[i]
	if c == n // 2:
		a1 = i
	if c > n // 2:
		a2 = i
		break
if a1 == -1 or a2 == -1:
	print(0)
else:
	print(a2 - a1)


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


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