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

l = d[int(len(d)/2) -1] + 1
u = d[int(len(d)/2)]
if l > u:
    print(0)
else:
    print(len(range(l, u+1)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

array = sorted(list(map(int, input().split())))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
sorted_d = sorted([int(d) for d in input().split()])
len_d = N//2
mid_d = sorted_d[len_d-1:len_d+1]
print(mid_d[1]-mid_d[0])

Submission status: Accepted

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

d.sort()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()

n = int(N/2)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
d = [int(i) for i in input().split()]

d.sort()
ans = d[(n - 1) // 2 + 1] - d[(n - 1) // 2]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

d.sort()
a=d[(N-1)//2]
b=d[(N+1)//2]
print(b-a)

Submission status: Accepted

Solution code:
def solve(n, D):
    D.sort()
    return D[n // 2] - D[n // 2 - 1]

_n = int(input())
_D = list(map(int, input().split()))
print(solve(_n, _D))

Submission status: Accepted

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

d_sorted = sorted(d)
k_l = d_sorted[(n//2)-1]
k_r = d_sorted[(n//2)]

print(k_r - k_l)

Submission status: Accepted

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

D.sort()
c = 0
b = False
for d in D:
    c += 1
    if b:
        if d != half:
            print(d - half)
        else:
            print("0")
        break
    if c == N // 2:
        half = d
        b = True

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 5分．easy !

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

Submission status: Accepted

Solution code:
n = int(input())
l = [int(_) for _ in input().split()]
#print(l)
l = sorted(l)
#print(l)
a = l[int(n/2)-1]
b = l[int(n/2)]
print(b-a)

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:
def main(N, d):
    d.sort()
    i = (N // 2) - 1
    return d[i+1] - d[i] if d[i] != d[i+1] else 0

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

Submission status: Accepted

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

d_sorted = sorted(d)

k_lst = range(d_sorted[(n//2)-1], d_sorted[(n//2)])

print(len(k_lst))

Submission status: Accepted

Solution code:
N = int(input())
*D, = map(int, input().split())
D.sort()
start = D[N//2 - 1] + 1
end = D[N//2] + 1
print(len([x for x in range(start, end)]))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
h=len(a)//2
a.sort()
print(a[h]-a[h-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:
import bisect
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:
def main():
    n=int(input())
    D=map(int,input().split())
    L=sorted(D)
    m=n//2
    print(L[m]-L[m-1] if L[m]>L[m-1] else 0)
main()

Submission status: Accepted

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

mid_l = len(d)//2 - 1
mid_r = mid_l + 1
print(d[mid_r] - d[mid_l])

Submission status: Accepted

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

    ans = 0
    
    num_list.sort()

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

    for i in range(left,right+1):
        ans += 1
            
    print(ans)

if __name__ == '__main__':
    main()

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:
n,*d=map(int,open(0).read().split())
h=n//2
d.sort()
print(d[h]-d[h-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

new = sorted(li, reverse=True)

m = math.floor(N/2)

ans = new[m-1] - new[m]

print(ans)

Submission status: Accepted

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

a.sort()
mid = int(n / 2)
if a[mid] != a[mid - 1]:
  print(a[mid] - a[mid - 1])
else:
  print(0)

Submission status: Accepted

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

center = d[int(len(d) / 2) - 1]
ans = 0
while center + 1 <= d[int(len(d) / 2)]:
  ans += 1
  center += 1
print(ans)

Submission status: Accepted

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

answer = (problem[middle_index] - problem[middle_index-1])
print(answer)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string
from functools import lru_cache

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

MOD = int(1e09) + 7

def main():
    N = cin.int()
    D = cin.mapInt()
    D.sort()
    print(D[N // 2] - D[N // 2 - 1])
    return

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
# print(n)
di=[]
for i in map(int,input().split()):
    di.append(i)
di.sort()
n1=int(n/2)
m=di[n1] -di[n1-1]
print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

d.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, d: "List[int]"):
    d.sort()
    s = d[N//2-1]
    e = d[N//2]
    print(e-s)
    return



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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
def LI():
  return [int(s) for s in input().split()]

d_s = LI()
d_s = sorted(d_s)

if len(d_s) % 2 != 0:
  print(0)
  exit()
  
upper = len(d_s) // 2
lower = upper - 1

print(d_s[upper] - d_s[lower])

Submission status: Accepted

Solution code:
import bisect

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

d.sort()
i = d[0]
a = 0
for v in d:
    a = bisect.bisect_left(d, v)
    if a>=int(n/2):
        break

if a >int(n/2):
    print(0)
else:
    print(d[a]-d[a-1])

Submission status: Accepted

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

Submission status: Accepted

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

d=sorted(d)

l=d[int(len(d)/2)-1]
r=d[int(len(d)/2)]

print(r-l)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# ALC 005 C

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

#print(lists)
print(lists[N//2]-lists[N//2-1])

Submission status: Accepted

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

Submission status: Accepted

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

D = sorted(D)
minK, maxK = D[N//2-1], D[N//2]
print(maxK - minK)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

D.sort()



teisu = N[0] // 2

print(abs(D[teisu]-D[teisu-1]))

Submission status: Accepted

Solution code:
number_problem = int(input())
level_list = list(map(int,input().split()))
  
level_list.sort()

print(level_list[int(number_problem/2)]-level_list[int(number_problem/2)-1])

Submission status: Accepted

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

d.sort()

left=d[len(d)//2-1]
right=d[len(d)//2]

print(right - left)

Submission status: Accepted

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

Submission status: Accepted

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

di.sort()

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

Submission status: Accepted

Solution code:
k=int(input())
d=sorted(list(map(int,input().split())))
ans=0
for i in range(d[int(len(d)/2)-1]+1,d[int(len(d)/2)]+1):
    ans+=1
print(ans)

Submission status: Accepted

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

    avr = len(d)//2 - 1
    if d[avr] == d[avr+1]:
        print(0)
    else:
        res = [i for i in range(d[avr]+1,d[avr+1]+1)]
        print(len(res))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        d = list(map(int, input().split()))

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


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
d = list(sorted([int(i) for i in input().split()]))
l = len(d) // 2
boundary = d[l - 1]
next_d = boundary
boundary_cnt = 0
for i in d[l:]:
    if i == boundary:
        boundary_cnt += 1
        if boundary > 2:
            next_d = boundary
            break
    elif i > boundary:
        next_d = i
        break
print(next_d - boundary)

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:
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    n = ri()
    la = rli()
    la.sort()
    h = (n-1)//2
    print(la[h+1]-la[h])



if __name__ == '__main__':
    main()

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

floor=d[N//2-1]
ceil=d[N//2]

print(ceil-floor)

Submission status: Accepted

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

d = sorted(d)

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

Submission status: Accepted

Solution code:
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

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

l = sorted(l)
a = l[n//2-1]
b = l[n//2]

#print(a,b)

if a==b:
	print(0)
	exit()
else:
	print(b-a)

Submission status: Accepted

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

def main():
    N = int(input())
    d = list(map(int, input().split()))
    sod = sorted(d)


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


main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


d.sort()
if d[N // 2] == d[N // 2 - 1]:
    print(0)
    exit()
ans = d[N // 2] - d[N // 2 - 1]
print(ans)

Submission status: Accepted

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

problems.sort()

divider = K // 2
ABC = problems[:divider]
ARC = problems[divider:]

print(ARC[0] - ABC[-1])

Submission status: Accepted

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

l=d[n//2-1]
r=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())
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()
l, r = d[n//2-1], d[n//2]
print(r-l)

Submission status: Accepted

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

Submission status: Accepted

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

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

a, b = l[:n//2], l[n//2:]

if a[-1] == b[0]:
    print(0)
else:
    print(b[0] - a[-1])

Submission status: Accepted

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

ls_s = sorted(ls)

i = n // 2

print(ls_s[i] - ls_s[i-1])

Submission status: Accepted

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

Submission status: Accepted

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

k = 0
ans = 0

half = n // 2 - 1

if ds[half] == ds[half + 1]:
    print(0)
else:
    print(ds[half + 1] - ds[half])

Submission status: Accepted

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

    return d[n] - d[n-1]

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

Submission status: Accepted

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

Submission status: Accepted

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

D.sort()
l = D[n // 2 - 1]
r = D[n // 2]

print(r - l)

Submission status: Accepted

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

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()))
if(len(d)%2 == 0):
    d.sort()
    t = int(len(d)/2)-1
    print(d[t+1] - d[t])
else:
    print(0)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
if(len(d)%2 == 0):
    d.sort()
    t = int(len(d)/2)-1
    s = d[t]
    m = s
    i = t
    while (d[t+1] > s):
        s += 1
    print(s-m)
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()
d1=d[len(d)//2-1]
d2=d[len(d)//2]

print(len(range(d1+1,d2+1)))

Submission status: Accepted

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

n = len(d)
h = n//2
l = n//2 - 1

if d[l] == d[h]:
    print(0)
else:
    s = d[h] - d[l]
    print(s)

Submission status: Accepted

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

d = sorted(d)

x = n // 2

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

Submission status: Accepted

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

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

Submission status: Accepted

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

d = sorted(d)

mid_d = d[n//2-1]
mid_m = d[n//2]
print(mid_m-mid_d)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    d1, d2 = sorted(map(int, input().split()))[n//2-1:n//2+1]
    print(d2 - d1)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
n = int(input())
d_ls = [int(i) for i in sys.stdin.readline().split()]
if n % 2 == 1:
    print(0)
else:
    d_ls.sort()
    print(d_ls[n//2] - d_ls[n // 2 - 1])

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:
#ABC132_C
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:
#ABC-132-C
N = int(input())
D = list(map(int, input().split()))
sorted_D = sorted(D)
ans = 0

half = (len(D) // 2) - 1

if sorted_D[half] != sorted_D[half+1]:
    ans = sorted_D[half+1] - sorted_D[half]
else:
    ans = 0
    
print(ans)

Submission status: Accepted

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

e=sorted(d)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())
D = np.array(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:
def calculate(arr):
    length = len(arr)
    s1 = (length // 2) - 1
    s2 = (length // 2)

    if arr[s2] == arr[s1]:
        return 0
    else:
        return arr[s2] - arr[s1]

N = int(input())

if N == 0:
    result = 0
else:
    list = list([int(s) for s in  input().split(" ")])
    list.sort()
    result = calculate(list)

print(result)

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())))
m=int(n/2)
print(d[m]-d[m-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

A = sorted(A)

i = N//2

if A[i] == A[i-1]:
    print(0)
else:
    print(A[i] - A[i-1])

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

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

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    d = LI()
    d = sorted(d)
    ans = d[N//2] - d[N//2 - 1]
    print(ans)

main()

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split()))
if n % 2 == 1:
    print(0)
    exit()
ps = sorted(p)
# print(ps, ps[len(ps)//2-1], ps[len(ps)//2])
print(ps[len(ps)//2] - ps[len(ps)//2-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

    right = difficulties[n // 2]
    left = difficulties[(n // 2) - 1]
    ans = right - left
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()

left = int((len(d)/2)-1)
right = int(len(d)/2)

cnt = 0
for i in range(d[left]+1,d[right]+1):
    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
# 22:39
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()))
n = int(N/2)
sortd = sorted(d)
a = sortd[n-1]
b = sortd[n]
print(b-a)

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