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:
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 statistics as st

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

c1 = st.median_low(d)
c2 = st.median_high(d)

print(abs(c1-c2))

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
d.sort(key=int)
if d[int(n/2)]==d[int(n/2)-1]:
  print(0)
else:
  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()
print(d[N//2] - d[N//2-1])

Submission status: Accepted

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

count = d_sorted[(N-1) //2 + 1] - d_sorted[(N-1) // 2]
print(count)

Submission status: Accepted

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

t=N//2
print(dd[t]-dd[t-1])

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    d = LI()
    d.sort()

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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
l=[int(i) for i in input().split()]
l.sort()
print(max(0,l[int(N/2)] - l[int(N/2)-1]))

Submission status: Accepted

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

Submission status: Accepted

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

d = sorted(d)

idx = int(N/2)

l = d[:idx][-1]
r = d[idx:][0]

print(r - l)

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 = list(map(int,input().split()))

d.sort()

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

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().strip())
d_lst = sorted([int(x) for x in stdin.readline().strip().split()])

bef = d_lst[len(d_lst)//2-1]
aft = d_lst[len(d_lst)//2]

print(aft - bef)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
*D,=map(int,input().split())

for i in range(N):
    D[i]=(D[i],i)
D=sorted(D)
print(D[N//2][0]-D[N//2-1][0])

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
sd = sorted(d)
#Kとしてあり得る値は sd[N // 2 - 1] + 1 から d[N // 2] までの合計 d[N // 2] - d[N // 2 - 1] 個
print(sd[N//2]-sd[N//2-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())
D = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
import math
n=int(input())
a=[int(i) for i in input().split()]
a=sorted(a)
c=(len(a)//2)-1
if(a[c+1]==a[c]):
    print(0)
else:
    print(abs(a[c]-a[c+1]))

Submission status: Accepted

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instr = lambda: sys.stdin.readline()
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
D = inintl()

D.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = sorted(list(map(int, input().split())))
print(d[n//2] - d[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())
d = sorted(list(map(int,input().split())))
#print(d)
cnt = 0
import bisect
for k in range(1,d[n-1]+1):
    if bisect.bisect_left(d,k) == n//2:
        cnt += 1
        #print(bisect.bisect_left(d,k))
        #print(k)
print(cnt)

Submission status: Accepted

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

halfLength = int(len(sorted_d) / 2)

if sorted_d[halfLength-1] ==  sorted_d[halfLength]:
	print(0)
else:
	print(sorted_d[halfLength] - sorted_d[halfLength-1])

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
d.sort()
num = 0
n3 = n//2
n2 = n3-1
if d[n2] == d[n3]:
    print(0)
else:
    for i in range(d[n2],d[n3]):
        num += 1
    print(num)

Submission status: Accepted

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

d.sort()

n = int(N / 2)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

num = d[N // 2 - 1]
ans = 0
for i in range(10**5):
    num += 1
    if d[N // 2 - 1] < num <= d[N//2]:
        ans += 1
    if num > d[N//2]:
        break
print(ans)

Submission status: Accepted

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

d.sort()

n = N // 2

t1 = d[n - 1]
t2 = d[n]

print(t2 - t1)

Submission status: Accepted

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

ds.sort()

d_miman = ds[N // 2 -1]
d_ijyou = ds[N // 2]

print(d_ijyou - d_miman)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
if len(d)%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())
d = [int(xi) for xi in input().split()]

d = sorted(d)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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()
n //= 2

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Ds = list(mapint())
Ds.sort()
MIN = Ds[N//2-1]
MAX = Ds[N//2]

if MIN==MAX:
    print(0)
else:
    print(MAX-MIN)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=lnii()
l.sort()

inx=n//2-1
print(l[inx+1]-l[inx])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort()
mida = A[N//2-1]
midb = A[N//2]
if mida == midb:
  print(0)
else:
  ans = midb-mida
  print(ans)

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# abc132_c.py
# https://atcoder.jp/contests/abc132/tasks/abc132_c

# C - Divide the Problems /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 300点

# 問題文
# 高橋君は、 N個の競技プログラミング用の問題をつくりました。 
# それぞれの問題には 1 から N の番号がついており、問題 i の難易度は整数 diで表されます(大きいほど難しいです)。
# 高橋君はある整数 Kを決めることで、

#     難易度が K以上ならば「 ARC用の問題」
#     難易度が K未満ならば「 ABC用の問題」

# という風に、これらの問題を二種類に分類しようとしています。

# 「ARC用の問題」と「ABC 用の問題」が同じ数になるような整数 Kの選び方は何通りあるでしょうか。

# 制約
#     2≦N≦105
#     Nは偶数である。
#     1≦di≦105
#     入力は全て整数である。

# 入力
# 入力は以下の形式で標準入力から与えられます。
# N
# d1 d2 ... dN

# 出力

# 「ARC用の問題」と「ABC 用の問題」が同じ数になるような整数 Kの選び方の数を出力してください。

# 入力例 1
# 6
# 9 1 4 4 6 7

# 出力例 1
# 2

# K=5,6としたとき、問題 1,5,6 が「ARC 用の問題」、問題 2,3,4 が「ABC 用の問題」となり、
# 条件を満たします。 よって、答えは 2通りです。

# 入力例 2
# 8
# 9 1 14 5 5 4 4 14

# 出力例 2
# 0

# 「ARC用の問題」と「ABC 用の問題」が同じ数になるような整数 Kの選び方が存在しない場合もあります。

# 入力例 3
# 14
# 99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1

# 出力例 3
# 42685


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    N = int(lines[0])
    # X, A = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(6):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(M):
    #     valueses.append(list(map(int, lines[i+1].split())))

    values.sort()
    n = int(N/2)

    log(f'values=[{values}]')
    result = values[n] - values[n-1]

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['6', '9 1 4 4 6 7']
        lines_export = [2]
    if pattern == 2:
        lines_input = ['8', '9 1 14 5 5 4 4 14']
        lines_export = [0]
    if pattern == 3:
        lines_input = ['14', '99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1']
        lines_export = [42685]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
import heapq as hq
gcd = math.gcd
n = ni()
D = list(ma())
D.sort()
print(D[n//2] - D[(n-1)//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:
N=int(input())
d=list(map(int,input().split()))
d.sort()
print(max(0,d[N//2]-d[N//2-1]))

Submission status: Accepted

Solution code:
import sys
N = int(input())
d = list(map(int, input().split()))
if len(d) % 2 != 0:
    print(0)
    sys.exit()
d.sort()
if d[N//2] == d[N//2-1]:
    print(0)
else:
    print(d[N//2] - d[N//2-1])

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest


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

    d.sort()

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

    print(r - l)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """6
9 1 4 4 6 7"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """8
9 1 14 5 5 4 4 14"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """14
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1"""
        output = """42685"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

d1,d2=d[N//2-1],d[N//2]
print(d2-d1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

Submission status: Accepted

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

n = int(input())

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

Submission status: Accepted

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

D.sort()
l = len(D)
lower = D[(l // 2) - 1]
upper = D[(l // 2)]

print(upper - lower)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
li = list(map(int, input().split()))
li.sort()
a = li[N//2]
flag = True
for i in range (N//2):
    if a == li[i]:
        flag = False
if flag:
     print(li[N//2]-li[N//2-1])
else:
     print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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:
N = int(input())
d = list(map(int, input().split()))

d.sort()
n = N // 2

print(d[n:][0] - d[:n][-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#create date: 2020-07-20 13:38

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    d = na()
    d.sort()
    dl = d[n//2-1]
    dr = d[n//2]
    if dl == dr:
        print(0)
    else:
        print(dr - dl)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

d.sort()

s = d[N//2-1]
e = d[N//2]
K = e - s 
print(K)

Submission status: Accepted

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

Submission status: Accepted

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

def main(n,d):
    ds=sorted(d)
    m=n//2
    if ds[m-1]==ds[m]:
        return 0
    else:
        return ds[m]-ds[m-1]

if __name__=='__main__':
    n,d=readinput()
    ans=main(n,d)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
dic = {}
ABCs = 0
count = 0
flag = 0

for i in range(N):
    if D[i] in dic:
        dic[D[i]] += 1
    else:
        dic[D[i]] = 1

diffs = sorted(dic.keys())

for k in range(diffs[-1]+1):
    if flag == 0:
        if ABCs == N / 2:
            count += 1
            flag += 1
    else:
        if ABCs > N / 2:
            break
        count += 1

    if k in dic:
        ABCs += dic[k]

print(count)

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
dic = {}
ABCs = 0
count = 0

for i in range(N):
    if D[i] in dic:
        dic[D[i]] += 1
    else:
        dic[D[i]] = 1

diffs = sorted(dic.keys())

for i in range(diffs[-1]+1):
    if i in dic:
        ABCs += dic[i]
    if ABCs == N / 2:
        count += 1

print(count)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
a=int(n/2)
s=l[a-1]
t=l[a]
if s==t:
  print("0")
else:
  ans=t-s
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#<132>
N = int(input())
d = list(map(int, input().split()))
d.sort()
ans = d[len(d) // 2] - d[len(d) // 2 - 1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
d = sorted(d)
length = len(d)
half1 = d[int(length/2)-1]
half2 = d[int(length/2)]
if half1 == half2:
  print(0)
else:
  print(half2-half1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    inlis = list(map(int,input().split()))
    inlis.sort()

    left = inlis[int(n//2)-1]
    right = inlis[int(n//2)]

    print(right-left)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

ans = D[right] - D[left]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
D = rl()

D.sort()

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

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

print(d2-d1)

Submission status: Accepted

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





#上は含みつつ、↓は含まない想定ね

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 13, 2020 04:49:37 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from sys import stdin
input = stdin.readline


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

  D = sorted(D)
  l = D[len(D)//2-1]
  r = D[len(D)//2]

  print(r-(l+1)+1)


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

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:
import sys


def input():
    return sys.stdin.readline().rstrip()


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a = n // 2
b = a - 1

print(d[a] - d[b])

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())
dl = list(map(int,input().split()))
dl.sort()

if n % 2 != 0:
  print(0)
  exit()

  
left = dl[(n//2)-1]
right = dl[(n//2)]

print(right-left)

Submission status: Accepted

Solution code:
N = int(input())
A= list(map(int, input().split()))
A=sorted(A)
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.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()

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

print(ans)

Submission status: Accepted

Solution code:
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

n=int(input())
d=input_array()
d.sort()
center=int(n/2)
ans=d[center] - d[center -1] 

print(ans)

Submission status: Accepted

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

half = int(n/2)

n1 = d[half-1]
n2 = d[half]

if n2-n1 == 0:
    print(0)
    exit()
else: 
    print(n2-n1)

Submission status: Accepted

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

Submission status: Accepted

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

d = sorted(d)

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

Submission status: Accepted

Solution code:
#13
N = int(input())
d = list(map(int,input().split()))
h = 0

d.sort()

h = int(N/2)

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

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()

result = d[int(N/2)] - d[int(N/2) - 1]

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
#h, w, k = list(map(int, input().split()))
# A = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# q = int(input())
p = list(map(int, input().split()))
# b = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# ab = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
p.sort()
a = p[n//2]
b = p[n//2-1]
if a == b:
    print(0)
else:
    print(a-b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
number = list(map(int,input().split()))
number.sort(reverse=True)
a = int((N/2)-1)
b = int(N/2)
print(number[a]-number[b])

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

new_l = sorted(l)
half1 = new_l[N//2-1]
half2 = new_l[N//2]

print(half2-half1)

Submission status: Accepted

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

new_l = sorted(l)
half1 = new_l[N//2-1]
half2 = new_l[N//2]

if half1 == half2:
    print(0)
else:
    print(half2-half1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    D = sorted(list(map(int, input().split())))
    a = D[N//2 - 1]
    b = D[N//2]
    ans = 0
    if a < b:
        ans = b - a
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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()
res = D[(N - 1) // 2 + 1] - D[(N - 1) // 2]
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = input().split(' ')
D = [int(D[i]) for i in range(N)]
D = sorted(D)
if not N%2 == 0:
  print(0)
else:
  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()
ans = d[n//2] - d[n//2-1]
print(ans)

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:
n = int(input())
d = sorted(list(map(int, input().split())))
dl = len(d)

if not dl%2 == 0:
    print(0)
    exit()
else:
    dl_mid_1 = dl//2
    dl_mid_2 = dl_mid_1 + 1
    k_min = d[dl_mid_1 - 1]
    k_max = d[dl_mid_2 - 1]
    print(k_max - k_min)

Submission status: Accepted

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

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

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