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

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

Submission status: Accepted

Solution code:
n = int(input())
d = input().split()
t = []

for i in range(n):
    t.append(int(d[i]))

t.sort()

ans = t[int(n / 2)] - t[int((n / 2) - 1)]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
d=[i for i in map(int,input().split())]
d.sort(reverse=False)

a=d[:N//2]
b=d[N//2:]
a.sort(reverse=False)
b.sort(reverse=False)

print(b[0]-a[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 = sorted(D)
n = int(N/2)

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

Submission status: Accepted

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

sortD = sorted(D)
print(sortD[int(N/2)] - sortD[int(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())
a=list(map(int,input().split()))
a.sort()
med_1=a[n//2-1]
med_2=a[n//2]
#print(med_1,med_2)
print(med_2-med_1)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,*D = map(int,read().split())

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

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


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

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






if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
D = [int(d) for d in 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()
i = n//2
a = d[i-1]
b = d[i]
ans = 0
for j in range(a+1,b+1):
  ans+=1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
D=map(int,input().split())
S=sorted(D)
print(S[N//2]-S[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()))

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

Submission status: Accepted

Solution code:
N = int(input())
D = 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)
half_num = len(d) // 2
ans = d[half_num] - d[half_num - 1]
print(ans)

Submission status: Accepted

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

import heapq

heapq.heapify(d)

for i in range(n//2-1):
	heapq.heappop(d)
	
a=heapq.heappop(d)
b=heapq.heappop(d)

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

Submission status: Accepted

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

Submission status: Accepted

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

centerl = int(len(m_L)/2-1)
centerr = int(len(m_L)/2)

print(sorted(m_L)[centerr] - sorted(m_L)[centerl])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, *d = map(int, open(0).read().split())
    d.sort()
    print(d[N // 2] - d[N // 2 - 1])
    return


main()

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    d = list(map(int, input().rstrip('\n').split()))
    d.sort()
    print(abs(d[n // 2] - d[n // 2 - 1]))


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

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

sorted_D = sorted(D)
left = sorted_D[int((n - 1) / 2)]
right = sorted_D[int(n / 2)]

if left == right:
    print(0)

else:
    print(right - left)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
D=list(map(int,input().split()))
D.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

# dの真ん中の2つの値の間の数が求める値
d = sorted(d)
l = d[int(N/2-1)]
r = d[int(N/2)]

print(r-l)

Submission status: Accepted

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

d2=sorted(d)
l=(d2[int(n/2)-1])
r=(d2[int(n/2)])
print(r-l)

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
d_lis=sorted(d)
ans=0
if d_lis[n//2-1]==d_lis[n//2]:
  ans=0
else:
  ans=d_lis[n//2]-d_lis[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())
a=list(map(int,input().split()))

a=sorted(a)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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()
#print(d)

d_len = len(d)

if d_len % 2 == 0:
    up = int(d_len/2)
    down = int(d_len/2) - 1
    if up == down:
        print('0')
    else:
        print(d[up]-d[down])
            
        

else:
    print('0')

Submission status: Accepted

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

D = sorted(d)

answer = 0
length = len(d)

if D[length//2-1] == D[length//2]:
    print(answer)
else:
    l = []
    i = D[length//2-1]
    while i+1 <= D[length//2]:
        l.append(i+1)
        i +=1
    answer = len(l)
    print(answer)

Submission status: Accepted

Solution code:
import sys
N = int(input())
D = list(map(int,input().split()))
#print(D)
center = N / 2

x = sorted(D)
#print(x)
num = x[int(center)] - x[int(center)-1]
print(num)

Submission status: Accepted

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

result = d[center] - d[center - 1]

print(result)

Submission status: Accepted

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

h = int(n / 2)

x = d[h] - d[h - 1]

if x > 0:
  print(x)
else:
  print(0)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ks = sorted(list(map(int, input().split())))
    a, b = ks[n//2-1:n//2+1]
    if a == b:
        print(0)
    else:
        print(b-a)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

d.sort()
if d[len(d)//2] == d[len(d)//2 - 1]:
      print(0)
else:
      print(d[len(d)//2] - d[len(d)//2 - 1])

Submission status: Accepted

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

if N % 2 == 1:
    print(0)
else:
    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()

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

Submission status: Accepted

Solution code:
# AtCoder
N = int(input())
lst = [int(x) for x in input().split()]
lst.sort()
# print(lst)  # original list
off = len(lst) // 2

front = lst[off - 1]
back = lst[off]

print(back-front)

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()

center = N // 2

L = d[:center]
R = d[center:]

# print(L,R)

ans = R[0] - L[-1]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#input : 問題数N、それぞれの難易度d_1からd_nまで
#output : 問題をちょうど半分に分けることができるような難易度Kの値の個数

N = int(input())
d = list(map(int,input().split()))
d.sort()
ARC = []
ABC = []

for i in range(N//2):
    ABC.append(d[i])
    ARC.append(d[-(i+1)])

boundaryARC = min(ARC)
boundaryABC = max(ABC)

if boundaryABC == boundaryARC:
    print(0)

else:
    print(boundaryARC-boundaryABC)

Submission status: Accepted

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

d_min=d[N//2-1]
d_max=d[N//2]

print(d_max-d_min)

Submission status: Accepted

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


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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
ds = list(map(int,input().split()))
ds.sort()
print(ds[n//2 ] - ds[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:
def p_c():
    N = int(input())
    d = list(map(int, input().split()))

    d.sort()

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


if __name__ == '__main__':
    p_c()

Submission status: Accepted

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


def solve(N: int, d: "List[int]"):
    sorted_d = sorted(d)
    abc_max = sorted_d[N // 2 - 1]
    arc_min = sorted_d[N // 2]
    print(arc_min - abc_max)
    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()
ans = 0
start_num = d[int(n / 2 - 1)]
end_num = d[int(n / 2)]

ans = end_num - start_num

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
d = [int(i) for i in input().split(" ")]
d = sorted(d)

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

if N % 2 == 1:
    print(0)
else:
    sed_d = sorted(d)
    sed_l = len(sed_d)
    l = sed_d[(sed_l//2)-1]
    r = sed_d[sed_l//2]
    K_list = list(range(l+1,r+1))
    print(len(K_list))

Submission status: Accepted

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

ans = 0

for i in range(a[int((n/2)-1)], a[int(n/2)]):
  ans += 1

print(ans)

Submission status: Accepted

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

n = N//2 - 1
ans = D[n+1] - D[n]
print(ans)

Submission status: Accepted

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

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())
l=list(map(int, input().split()))
i=int(len(l)/2)
l.sort()
ll=list(range(l[i-1]+1,l[i]+1))

print(len(ll))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

d_l = sorted(d_l)

m = d_l[(N//2) -1]
n = d_l[(N//2)]

print(n - m)

Submission status: Accepted

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

a.sort()

c1 = a[len(a)//2]
c2 = a[len(a)//2-1]
if c1 != c2:
    count = c1 - c2
print(count)

Submission status: Accepted

Solution code:
N = int(input())
d = sorted(list(map(int, input().split())))
min_K = d[N//2 - 1] + 1
max_K = d[N//2]
print(max_K - min_K + 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()))
sd = sorted(d, reverse=True)
print(abs(sd[int(len(sd)/2)-1]-sd[int(len(sd)/2)]))

Submission status: Accepted

Solution code:
N = int(input())
# 問題数が奇数のときは問題数が同じにはならない
if N%2==1:
    print(0)

di = sorted(list(map(int, input().split())))
first_of_center = di[int(len(di)/2)-1]
second_of_center = di[int(len(di)/2)]
#中央の2つの値が同じ時Kは選べない
if first_of_center == second_of_center:
    print(0)
else:
    print(second_of_center - first_of_center)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#C
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())))
i = n//2

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

Submission status: Accepted

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

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

Submission status: Accepted

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

n=int(input())
l = [int(i) for i in input().split()]
#heapq.heapify(l)
l.sort()
i=n//2

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

Submission status: Accepted

Solution code:
from sys import stdin
import itertools

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
li.sort()
key = n//2
print(li[key:][0]-li[:key][-1])

Submission status: Accepted

Solution code:
from sys import stdin
import itertools

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
li.sort()
key = n//2

if li[:key][-1] == li[key:][0]:
    print(0)
else:
    print(li[key:][0]-li[:key][-1])

Submission status: Accepted

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

changed=sorted(s,reverse=True)


if changed[int(n/2-1)]==changed[int(n/2)]:
        print(0)
else:
        print(-changed[int(n/2)]+changed[int(n/2-1)])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin

N = int(stdin.readline())
d = sorted(list(map(int,stdin.readline().split())))

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

Submission status: Accepted

Solution code:
n = int(input())

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

d.sort()

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

print(diff)

Submission status: Accepted

Solution code:
# ABC132 C - Divide the Problems
n = int(input())
d = list(map(int,input().split()))
d.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

for i in range(a+1,b+1):
  c +=1
  
print(c)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
 
if n % 2 == 1:
  print(0)
  exit()

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

Submission status: Accepted

Solution code:
#ABCC - Divide the Problems
N = int(input())
d = list(map(int,input().split()))
d.sort()
n = N//2
a = d[n-1]
b = d[n]
print(b-a)

Submission status: Accepted

Solution code:
#133c
N = int(input()) #偶数
d_list = list(map(int, input().split()))

d_list.sort()
#print(d_list)
#print(d_list[int(N/2)-1],d_list[int(N/2)])

if d_list[int(N/2)-1]==d_list[int(N/2)]:
    print("0")
else:
    print(d_list[int(N/2)]-d_list[int(N/2)-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

list_b = list_d[:int(n/2)]
list_r = list_d[int(n/2):]
print(len(list(range(list_b[-1] + 1, list_r[0] + 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())
d = list(map(int,input().split()))
if n %2 ==1:
    print(0)
else:
    d.sort()
    kmin = d[n//2-1]
    kmax = d[n//2]
    print(kmax - kmin)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

D.sort()
mid = N//2

count = 0
for i in range(D[mid-1]+1, D[mid]+1):
    count += 1

print(count)

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

D.sort()
mid = N//2

if D[mid-1] == D[mid]:
    print(0)
    exit()

count = 0
for i in range(D[mid-1]+1, D[mid]+1):
    count += 1

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

D_sorted = sorted(D)
sa = D_sorted[N // 2] - D_sorted[N // 2 - 1]
ans = sa
if ans <= 0:
    print(0)
else:
    print(ans)

Submission status: Accepted

Solution code:
N=int(input())

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

a=sorted(m)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(b-a)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left
from math import factorial


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
L = sorted(LI())
if L[n // 2] == L[n // 2 - 1]:
    print(0)
else:
    print(L[n // 2] - L[n // 2 - 1])

Submission status: Accepted

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

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

Submission status: Accepted

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

d.sort()
print(len(range(d[n // 2 - 1] + 1, d[n // 2] + 1)))

Submission status: Accepted

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

t = sorted(l)

index = len(t)//2

ans = t[index] - t[index-1]

print(ans)

Submission status: Accepted

Solution code:
# -*- coding:utf8 -*-

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

Submission status: Accepted

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

d.sort()

div = N // 2

b_max = d[div - 1]
r_min = d[div]

print(r_min - b_max)

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:][0]
print(right-left)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main(): 

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

    low_middle = len(d) // 2 - 1
    high_middle = len(d) // 2

    if d[low_middle] == d[high_middle]:
        print('0')
    else:
        print( d[high_middle] - d[low_middle])




if __name__ == "__main__":
    main()

Submission status: Accepted

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

d.sort()
print(max(d[n//2] - d[n//2-1], 0))

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

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()
div_min = d[int(n/2-1)]
div_max = d[int(n/2)]

count = div_max - div_min
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def test():
    n = int(input())
    a = sorted(list(map(int,input().split())))
    b = a[n//2]; c = a[n//2-1]
    count = 0
    if sum(i<b for i in a) == sum(i>=b for i in a):
        print(b-c)
    else:
        print(0)


if __name__ == "__main__":
    test()

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

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 = N//2-1
if d[n] == d[n+1]:
    print(0)
    exit()
ans = 0
for i in range(d[n], d[n+1]):
    ans += 1
print(ans)

Submission status: Accepted

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

e = sorted(d)
if e[int(n/2)-1] == e[int(n/2)]:
	print(0)
else:
	print(e[int(n/2)]- e[int(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:
while True:
    try:
        N = int(input())
        d = list(map(int, input().split()))
        d.sort()
        l = d[N//2-1]
        r = d[N//2]
        print(r-l)
    except:
        break

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()

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