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



Sample input:
6
9 1 4 4 6 7


Sample output:
2

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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)

Submission status: Accepted

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


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

print(q-p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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]

Submission status: Accepted

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

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

Submission status: Accepted

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

K = D[N//2] - D[N//2-1]
#print(D[N//2], D[N//2-1])
print(K)

Submission status: Accepted

Solution code:
# -*- coding utf-8 -*-

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

dn.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env 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])


# region fastio

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

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2019/06/29
# AtCoder Beginner Contest 132 - C

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

# Sort
d.sort()

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

ans = med2 - med1

# Output
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    print(solve(N, d))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

dn.sort()

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

Submission status: Accepted

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

d.sort()

ni = n // 2

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

print(k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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  # 0 ~ mid-1までがABC, mid~n-1がARC
    min_arc_idx = mid
    max_abc_idx = mid - 1

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


if __name__ == '__main__':
    submit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#入力取得
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)

Submission status: Accepted

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

d.sort()
l = n//2

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

Submission status: Accepted

Solution code:
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)
# MOD = 10 ** 9 + 7
# INF = float('inf')
# N = int(input())
# A = [int(x) for x in input().split()]
# A = [int(input()) for _ in range(N)]
# dp = [[0] * 100 for _ in range(100)]
# dp = defaultdict(lambda: float('inf'))
# print('hoge', file=sys.stderr)


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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
d = sorted(map(int, input().split()))
print(d[n // 2] - d[n // 2 - 1])

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  # 経路圧縮
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


n = II()
d = sorted(LI())
print(d[n//2] - d[n//2-1])

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
D.sort()
D_len = len(D)
border = D_len//2

if D[border] == D[border - 1]:
    ans = 0
else:
    ans = D[border] - D[border - 1]

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# lbとubの差っぽい
# と思ったけど単純に[n//2]-[n//2-1]か
n = int(input())
arr = list(sorted(list(map(int, input().split()))))
print(arr[n//2] - arr[n//2 - 1])

Submission status: Accepted

Solution code:
N=int(input())
lst=sorted(list(map(int,input().split())))

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    n = II()
    d = LI()

    d.sort()

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


main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
d = list(map(int,input().split()))
d.sort()

i_min = n//2 -1
i_max = n//2
v_min = d[i_min]
v_max = d[i_max]

print(v_max-v_min)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


def solv(n, d):
    d = sorted(d)
    min_ = d[n // 2 - 1] + 1
    max_ = d[n // 2]
    if min_ > max_:
        return 0
    else:
        return max_ - min_ + 1



if __name__ == '__main__':

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

    ans = solv(n, d)

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

dlist.sort()

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

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())  
d = np.array(input().split(), dtype=np.int64)

d_sort = np.sort(d)
d_size = len(d)


print(d_sort[int(d_size/2)] - d_sort[int(d_size/2 - 1)])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
K=list(map(int,input().split()))
K.sort()
mid1,mid2=K[n//2-1],K[n//2]
print(mid2-mid1)

Submission status: Accepted

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

d.sort()

if N % 2 == 1:
    print(0)
else:
    l = d[N // 2 - 1]
    r = d[N // 2]
    
    ans = r - l
    if ans > 0:
        print(ans)
    else:
        print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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

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

Submission status: Accepted

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

dsort = d.sort()

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

Submission status: Accepted

Solution code:
N = int(input())

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

left = N // 2 -1
right = N // 2

print(D_sorted[right] - D_sorted[left])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
num = list(map(int,input().split()))
num.sort()

ABC_upper = num[n//2-1]
ARC_lower = num[n//2]

print(ARC_lower - ABC_upper)

Submission status: Accepted

Solution code:
input()

x=list(map(int,input().split(' ')))

x=sorted(x,reverse=True)

temp1=x[int(len(x)/2)-1]
temp2=x[int(len(x)/2)]

print(temp1-temp2)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
	import sys
	input = sys.stdin.readline
	N = int(input())
	d = list(map(int, input().split()))
	d.sort()
	ind = int(N/2)
	if d[ind-1] == d[ind]:
		print(0)
	else:
		print(d[ind] - d[ind-1])

if __name__ == '__main__':
    main()

Submission status: Accepted

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

mid = n // 2

lower = d[mid - 1]
upper = d[mid]
diff = upper - lower
print(diff)

Submission status: Accepted

Solution code:
N = int(input())

mannaka = int(N/2)

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

DDD.sort()

left = DDD[:mannaka][-1]
right = DDD[mannaka:][0]

print(right-left)

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()
sita = d[n//2 - 1]
ue = d[n//2]
print(ue-sita)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    D = list(map(int, input().split()))
    D.sort()

    """
    1 4 4 | 6 7 9　OK

    1 4 4 | 4 7 9　だめ

    1 2 3 | 3 7 9  だめ
    """

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

    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
D=LIST()

D.sort()
D1=D[:N//2]
D2=D[N//2:]

print(D2[0]-D1[-1])

Submission status: Accepted

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

Submission status: Accepted

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

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


D.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = [int(_) for _ in input().split()]

d.sort()

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
import bisect
N = int(input())
Ds = sorted(list(map(int,input().split())))
index = len(Ds)//2
if Ds[index]== Ds[index-1]:
    print(0)
else:
    print(Ds[index]-Ds[index-1])
    #for k in range(Ds[index-1],Ds[index]):
        #print(k)

Submission status: Accepted

Solution code:
N = int(input())
d = sorted(list(map(int, input().split())))
a = d[(N//2)-1]
b = d[N//2]
if a == b:
    print(0)
else:
    print(b - a)

Submission status: Accepted

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

e = xs[n//2] 
b = xs[n//2-1]

print(e-b if e != b else 0)

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

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

n_d2 = int(n / 2)

sa = D[n_d2] - D[n_d2 -1]
print(sa)

Submission status: Accepted

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

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

    print(right_mid - left_mid)

Submission status: Accepted

Solution code:
import bisect

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

d.sort()

cnt = 0
for i in range(1, 10**5+1):
    index = bisect.bisect_left(d, i)
    if N - index == index:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
d_list = sorted([int(x) for x in input().split()])
print(d_list[N//2] - d_list[N//2-1])

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

Solution code:
n = int(input())
dn = list(map(int, input().split()))
dn.sort()
d1, d2 = dn[n//2-1:n//2+1]
print(d2-d1)

Submission status: Accepted

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

left = d[n//2 - 1]
right = d[n//2]

print(right-left)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N = int(input())
d = list(map(int, input().split()))
d.sort()
ans = d[N // 2] - d[N // 2 - 1]
print(ans)

Submission status: Accepted

Solution code:
import bisect

n = int(input())
d = list(map(int, input().split()))
d.sort()
div = n // 2
count = 0
for i in range(10**5 + 1):
    insert_index = bisect.bisect_right(d, i)
    if insert_index == div:
        count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ds = [int(elem) for elem in input().split()]
ds = sorted(ds)

m = n // 2

abc = ds[:int(m)]
arc = ds[int(m):]

print(arc[0] - abc[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

fin = sys.stdin.readline
n = int(fin())
d_list = [int(elem) for elem in fin().split()]

sort_d = sorted(d_list)
middle_d = int(n / 2)

if sort_d[middle_d] == sort_d[middle_d - 1]:
    print(0)
else:
    print(sort_d[middle_d] - sort_d[middle_d-1])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
m = int(N/2)
d = list(map(int,input().split()))
d.sort()

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

Submission status: Accepted

Solution code:
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

# N <= 10^5
# Nは偶数
N = int(stdin.readline().rstrip())
d = list(map(int, stdin.readline().rstrip().split()))

d.sort()

right = N // 2
left = right - 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
D = [int(d) for d in input().split()]
D.sort()
a,b = D[n//2-1], D[n//2]
print(b-a)

Submission status: Accepted

Solution code:
import bisect
N = int(input())
d_lis = sorted([int(item) for item in input().split()], reverse=False)

count = 0
for i in range(100000):
    if bisect.bisect(d_lis, i) == N / 2:
        count += 1
print(count)

Submission status: Accepted

Solution code:
inp = input()
n = int(inp)
inp = input()
split_inp = inp.split()
d_list = [int(st) for st in split_inp]
if n % 2 == 1 or n < 2:
    print(0)
    exit()
half = n // 2
d_list = sorted(d_list)
print(d_list[half] - d_list[half-1])

Submission status: Accepted

Solution code:
import bisect
N = int(input())
*d, = map(int, input().split())
d.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
assert N == len(D)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
difficulty = [int(x) for x in input().split()]
center = N//2

difficulty = sorted(difficulty)

ans = difficulty[center]-difficulty[center-1]

print("{}".format(ans))

Submission status: Accepted

Solution code:
a = int(input())
list_d = list(map(int, input().split()))
list_d.sort()
print(max(list_d[a//2] - list_d[a//2 - 1] , 0))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

Solution code:
N = int(input())
ds = [int(s) for s in input().split() if s]

half = N//2
ds = sorted(ds)
ret = ds[half] - ds[half-1]
print(ret)

Submission status: Accepted

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

d.sort()
h = int(N/2)

pre = d[h-1]
pos = d[h]

if pre==pos:
    print(0)
else:
    print(pos-pre)

Submission status: Accepted

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

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

Submission status: Accepted

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