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 = 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=sorted(d)
ans=0
 
for i in range(1+10**5):
    if d[int(N/2-1)] < i and i <= d[int(N/2)]:
        ans +=1
 
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
d=list(map(int, input().split()))
 
d=sorted(d)
ans=0
 
for i in range(10**6):
    if d[int(N/2-1)] < i and i <= d[int(N/2)]:
        ans +=1
 
print(ans)

Submission status: Accepted

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

d=sorted(d)
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()))
ans=0
di=sorted(d)
half1=di[(n-1)//2]
half2=di[(n-1)//2+1]
ans=half2-half1
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:
def resolve():
    '''
    code here
    '''
    N = int(input())
    Ds = [int(item) for item in input().split()]

    Ds.sort()

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

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

Submission status: Accepted

Solution code:
from math import gcd
n=int(input())
d=list(map(int,input().split()))
#昇順にソートする
d.sort()
mid_after=int(n/2)
mid_fore=mid_after-1
print(d[mid_after]-d[mid_fore])

Submission status: Accepted

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

D.sort()
m = int(len(D)/2)
print(D[m] - D[m - 1])

Submission status: Accepted

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

d = sorted(d)
x = int(N / 2)

print(int(d[x] - d[x-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()
num = N//2
ans = d[num]-d[num-1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    d = list(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    d.sort()
    md=d[-1]
    count=0
    for i in range(1,md+1):
        c=bisect_left(d,i)
        if N-c==c:
            count+=1
    print(count)





if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
d.sort()
ABC=[]
ARC=[]
for i in range(n):
    if i<n//2:
        ABC.append(d[i])
    else:
        ARC.append(d[i])
if max(ABC)==min(ARC):
    print(0)
else:
    num=abs(max(ABC)-min(ARC))
    print(num)

Submission status: Accepted

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

dl.sort()
d_half1 = dl[n//2-1]
d_half2 = dl[n//2]

print(d_half2-d_half1)

Submission status: Accepted

Solution code:
n, *dd = map(int, open(0).read().split())

dd.sort()

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

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    d = list(map(int, input().split()))
    d = sorted(d)
    if n%2 == 0: #偶数
        ans = d[n//2] - d[n//2 - 1]
    else: #奇数
        ans = 0
    print(ans)
resolve()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(k)

Submission status: Accepted

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

brr=sorted(arr)

if N%2==0:
    ans=brr[int(N//2)]-brr[int(N//2)-1]
else:
    ans=0

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]
N = int(input())
list_d = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
d_li = [int(w) for w in input().split()]
d_li.sort()

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

Submission status: Accepted

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

index = len(d) // 2 - 1

ans = 0
if d[index] != d[index + 1]:
    ans = d[index + 1] - d[index]
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

n_1=int(N/2)-1
n_2=int(N/2)
print(D[n_2]-D[n_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 = sorted(list(map(int, input().split())))

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-25 17:21:17 +0900
# LastModified: 2020-06-25 17:28:09 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    d = list(map(int, input().split()))
    d.sort()
#    print(d)
    if len(d)%2 == 1:
        print(0)
        return
    l = d[len(d)//2-1]
    r = d[len(d)//2]
    if l == r:
        print(0)
        return
    print(r-l)



if __name__ == "__main__":
    main()

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 = 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=[int(x) for x in 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())))

center_idx = N // 2
if d[center_idx-1] == d[center_idx]:
    print(0)
else:
    print(d[center_idx] - d[center_idx-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/ python3.8
N=int(input())
d=[int(x) for x in input().split()]
d.sort()
if N%2==1:
    print(0)
    exit(0)
x,y=d[N//2-1:N//2+1]
print(y-x)

Submission status: Accepted

Solution code:
#!/usr/bin/ python3.8
N=int(input())
d=[int(x) for x in input().split()]
d=sorted(d)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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

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

low  = D[0:N//2]
high = D[N//2::]

flg  = all( low[-1] + 1 >  x for x in low )
flg |= all( high[0] - 1 >= x for x in high )

if flg == True:
    print(high[0] - low[-1])
else:
    print(0)

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:
nb = int(input())
liste=[int(x) for x in input().split()]
liste.sort()
index1 = (nb//2)-1
index2 = (nb//2)
roger =liste[index2]-liste[index1]
print(roger)

Submission status: Accepted

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

d_sorted = sorted(D)

na = d_sorted[int(N/2)]
nb = d_sorted[int(N/2-1)]

print(na-nb)

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

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

Submission status: Accepted

Solution code:
n = int(input())
d = sorted(list(map(int,input().split())))
x = int(n/2)
abc = d[:x]
arc = d[x:]
cnt = 0
for i in range(max(abc)+1, min(arc)+1):
    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    N = ii()
    D = sorted(il())
    l = D[N // 2 - 1]
    r = D[N // 2]
    print(r - l)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
d=[int(x) for x in input().rstrip().split()]
d.sort()
ind=n//2

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

else:
  print(d[ind]-d[ind-1])

Submission status: Accepted

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

if n % 2 == 1:
    print(0)
else:
    m = n // 2
    print(D[m] - D[m - 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 sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *D = map(int, read().split())
    D.sort()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

max_n = max(d[:n2])
min_n = min(d[n2:])

ans = 0
for i in range(max_n+1,min_n+1):
    ans += 1

print(ans)

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=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()
s=n//2-1
a=d[s]
b=d[s+1]
if a==b:
  print(0)
  
else:
  print(b-a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if N % 2 != 0:
  print(0)
else:
  middle = N // 2 
  answer = d_list[middle] - d_list[middle - 1]
  print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def count_up(d, cut):
    ARC = len([1 for i in d if i >= cut])
    ABC = len(d) - ARC
    if ABC == ARC:
        return True
    return False

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

Submission status: Accepted

Solution code:
# template by 3xC and starkizard.
# contributors: 

#####################################################################################
from __future__ import division, print_function 

import sys
import os
from collections import Counter, deque, defaultdict
import itertools
import math
import io


"""Uncomment modules according to your need"""


# from bisect import bisect_left, bisect_right, insort
# from heapq import heappop, heapify, heappush
# from random import randint as rn
# from Queue import Queue as Q
# from copy import deepcopy
# from decimal import *
# import re
# import operator

#####################################################################################
# this enables you to write python3 code with PyPy2 (Python 2)
if sys.version_info[0] < 3:
    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip

#####################################################################################

"""value of mod"""
MOD = 998244353
mod = 10**9 + 7

"""Uncomment next 4 lines if doing huge recursion"""
# import threading
# threading.stack_size(1<<27)
# sys.setrecursionlimit(10000

def prepare_factorial(mod=mod):
    """ returns two lists, factorial and inverse factorial modulo argument by default 10**9 +7 """
    # Comment code out when you don't need inverse factorial or vice versa
    fact = [1]
    for i in range(1, 200005):
        fact.append((fact[-1] * i) % mod)

    ifact = [0] * 200005
    ifact[200004] = pow(fact[200004], mod - 2, mod)
    for i in range(200004, 0, -1):
        ifact[i - 1] = (i * ifact[i]) % mod

    return fact, ifact

def modinv(n, p):
    """ returns N inverse modulo p """
    return pow(n, p - 2, p)

def ncr(n, r,  fact, ifact):
    """ takes 4 arguments: n , r and factorial and inverse factorial lists"""
    t = (fact[n] * (ifact[r]*ifact[n-r]) % MOD)% MOD
    return t


def get_n(Sum):    
    """this function returns the maximum n for which Summation(n) <= Sum"""
    ans = (-1 + sqrt(1 + 8*Sum))//2
    return ans

def sieve(n):
    """ returns a list of prime numbers till n """
    if n < 2: return list()
    prime = [True for _ in range(n + 1)]
    p = 3
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 2
    r = [2]
    for p in range(3, n + 1, 2):
        if prime[p]:
            r.append(p)
    return r



def divs(n, start=1):
    """ returns a list of all divisors till n """
    divisors = []
    for i in range(start, int(math.sqrt(n) + 1)):
        if n % i == 0:
            if n / i == i:
                divisors.append(i)
            else:
                divisors.extend([i, n // i])
    return divisors



def divn(n, primes):
    """ returns the number of divisors, two arguments n and the sieve till n """
    divs_number = 1
    for i in primes:
        if n == 1:
            return divs_number
        t = 1
        while n % i == 0:
            t += 1
            n //= i
        divs_number *= t



def lrfind(d, x, default=-1):
    """ Takes 2 arguments an iterable and an element. returns a tuple (firstoccurence,lastoccurence) -1 if not found """
    left = right = -1
    for i in range(len(d)):
        if d[i] == x:
            if left == -1: left = i
            right = i
    if left == -1:
        return default, default
    else:
        return left, right

def gcd(x, y): # math.gcd is slower
    """ returns greatest common divisor of x and y """
    while y:
        x, y = y, x % y
    return x

def check_sorted(a):
    ''' returns True/False '''
    for i in range(len(a)-1):
        if a[i]>a[i+1]:
            return False
    return True
def ceil(n, k=1): return n // k + (n % k != 0) #returns math.ceil but protecting against floating inconsistencies
def input(): return sys.stdin.readline().strip()
def ii(): return int(input()) #inputs integer
def mi(): return map(int, input().split()) # inputting space seperated variables for example x,y,z
def li(): return list(map(int, input().split())) #inputting a space seperated list of integers
def lw(): return input().split() #inputting a space seperated list of strings
def lcm(a, b): return abs(a * b) // gcd(a, b) #returns LCM of two arguments
def prr(a, sep=' ', end='\n'): print(sep.join(map(str, a)), end=end) #For printing an iterable with seperator sep as optional second argument (default : " "), ending character (default: "\n") as optional third
def dd(): return defaultdict(int) #returns a dictionary with values defaulted to 0
def ddl(): return defaultdict(list) #returns a dictionary with values defaulted to []
def write(s): return sys.stdout.write(s)












###################################################################
def main():
    #CODE GOES HERE:
    n=ii()
    k=li()
    k.sort()
    print(k[n//2]-k[n//2-1])

""" -------- Python 2 and 3 footer by Pajenegod and c1729 ---------"""

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192

class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO, self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill();
            self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)


class IOWrapper(IOBase):

    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            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')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

""" main function"""

if __name__ == '__main__':
    main()
    # threading.Thread(target=main).start()

Submission status: Accepted

Solution code:
def actual(n, D):
    D.sort()

    idx = int(len(D) // 2)
    abc_max = D[:idx][-1]
    arc_min = D[idx:][0]

    k = 0

    for i in range(abc_max + 1, arc_min + 1):
        k += 1

    return k

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

print(actual(n, D))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    n = int(input())
    D = sorted(map(int, input().split()))
    abc = D[:n//2]
    arc = D[n//2:]
    print(arc[0] - abc[-1])



main()

Submission status: Accepted

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

count = 0
count2 = 0
d.sort()

le = len(d)//2
s = d[int(le)-1]
l = d[int(le)]
ans = 0
for i in range(s,l):
  ans += 1
if(ans == ""):
	print(0)
else:
    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())
D = list(map(int, input().split()))
D.sort()

d1, d2 = D[n // 2 - 1], D[n // 2]
ans = 0
if d1 != d2:
    ans = len(range(d1 + 1, d2 + 1))

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:
n = int(input())
m = n//2
D = list(map(int, input().split()))
D.sort()
D.reverse()
if D[m-1] == D[m]:
  print(0)
  exit()
else:
  print(D[m-1]-D[m])
  exit()

Submission status: Accepted

Solution code:
import sys


def main():
    n = int(sys.stdin.readline())
    d = list(map(int, sys.stdin.readline().split()))
    d.sort()
    h = n // 2
    print(d[h] - d[h - 1])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys


def main():
    n = int(sys.stdin.readline())
    d = list(map(int, sys.stdin.readline().split()))
    d.sort()
    half = n // 2
    print(d[half] - d[half - 1])


if __name__ == "__main__":
    main()

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d=[int(x) for x in input().rstrip().split()]
d.sort()
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()
k=int(n/2)-1
if d[k]==d[k+1]:
    print(0)
else:
    print(d[k+1]-d[k])

Submission status: Accepted

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

k_1 = l[(n//2)-1]
k_2 = l[(n//2)]
print(k_2-k_1)

Submission status: Accepted

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

l.sort()
mid_id = int((N / 2) - 1)
ans = l[mid_id+1] - l[mid_id]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
li=list(map(int,input().split()))
ans=0
li.sort()

H=int(N//2)

for i in range(1,10**5+1):
    if li[H-1]<i and li[H]>=i:
        ans+=1

print(ans)