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

d = {}
for x in s:
    if x in d:
        d[x] += 1
    else:
        d[x] = 1

s = sorted(list(set(s)))
count = 0
l = 0
for x in s:
    if l != 0:
        out += x-l
        break
    else:
        count += d[x]
        if count == N/2:
            l = x
print(out)

Submission status: Accepted

Solution code:
def main():
    _ = int(input())
    ds = list(map(int, input().split()))
    ds = sorted(ds)
    midpoint = len(ds) // 2
    if ds[midpoint] == ds[midpoint - 1]:
        score = 0
    else:
        score = ds[midpoint] - ds[midpoint - 1]

    print(score)


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:
#29 ABC132C
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:
#!/usr/bin/env python3
import sys


def solve(N: int, d: "List[int]"):
    d = sorted(d)
    low = d[N//2 - 1]
    high = d[N//2]
    print(high - low)
    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())
D = sorted(list(map(int, input().split())))
l, r = D[N//2-1], D[N//2]
print(r-l)

Submission status: Accepted

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

Submission status: Accepted

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

center = n // 2

if(arr[center] == arr[center-1]):
    result = 0
else:
    result = arr[center] - arr[center-1]

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import statistics
import math

n=int(input())
d=list(map(int, input().split())) #9 1 4 4 6 7

s_d=sorted(d)

median = s_d[n//2-1]

print(s_d[n//2]-median)

Submission status: Accepted

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

m = N // 2
a, b = d[m], d[m-1]

print(a- b)

Submission status: Accepted

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

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

p.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

d = sorted(d)

lower = d[N//2 -1]
upper = d[N//2]

print(len(range(lower, upper)))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

h = N//2

d_sorted = sorted(d_ls)
h_low = d_sorted[h-1]
h_high = d_sorted[h]


print(h_high - h_low)

Submission status: Accepted

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

Ds.sort()
mid = int(N / 2)
if Ds[mid] == Ds[mid-1]:
    print(0)
else:
    print(Ds[mid] - Ds[mid -1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    n = int(input())
    ds = sorted(list(map(int, input().split())))
    abc_max = ds[n // 2 - 1]
    arc_min = ds[n // 2]
    return arc_min - abc_max


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

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

d.sort()
h = n // 2

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

Submission status: Accepted

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

l = sorted(d)
abc = l[:n//2][-1]
arc = l[n//2:][0]

print(arc-abc)

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

Solution code:
from statistics import*
input()
d=list(map(int,input().split()))
print(median_high(d)-median_low(d))

Submission status: Accepted

Solution code:
N = int(input())
D = sorted(list(map(int, input().split())))
check = []
half = int(len(D)/2)
D_lead = D[:half]
D_tail = D[half:]
if max(D_lead) != min(D_tail):
    check = [num for num in range(max(D_lead), min(D_tail))]
    print(len(check))
else:
    print(0)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = sorted(A)
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(max(d[n//2] - (d[n//2 - 1] + 1) + 1, 0))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ds = list(map(int, input().split()))
    cs = [0] * 100001
    for d in ds:
        cs[d] += 1
    abc = 0
    res = 0
    for k in range(2, 100001):
        abc += cs[k - 1]
        if abc * 2 == n:
            res += 1
        elif abc * 2 > n:
            break
    print(res)


if __name__ == "__main__":
    main()

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:
def main():
  n = int(input())
  ds = list(map(int, input().split(' ')))
  ans = 0
  if n % 2 == 1:
    pass
  else:
    s = sorted(ds)
    l, r = s[n//2-1], s[n//2]
    if l == r:
      pass
    else:
      ans = r - l
  print(ans)


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
n = int(input())
d = sorted(list(map(int,input().split())))
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=[int(x) for x in input().split()]
if len(d_list)%2>0:
    print(0)
else:
    d_sort=sorted(d_list)
    half=int(len(d_list)/2)
    print(d_sort[half]-d_sort[half-1])

Submission status: Accepted

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

f=d[:len(d)//2]
l=d[len(d)//2:]

diff=l[0]-f[-1]

print(diff)

Submission status: Accepted

Solution code:
import sys

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

if len(d) % 2 == 1:
    print(0)
    sys.exit()

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

Submission status: Accepted

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

d = sorted(d)
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()
if len(list(set(d[:int(n/2)]).intersection(d[int(n/2):]))) != 0:
    print(0)
    exit()
else:
    print(d[int(n/2):][0] - 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()

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

Submission status: Accepted

Solution code:
def divide_problems(n,d):
    ans = 0
    _d = sorted(d)
    ans = _d[n/2] - _d[n/2-1]
    return ans

if __name__ == '__main__':
    n = int(raw_input())
    d = list(map(int,raw_input().split()))

    print divide_problems(n,d)

Submission status: Accepted

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

a.sort()
mid=int(len(a)/2)
print(a[mid]-a[mid-1])

Submission status: Accepted

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

sd = sorted(d)

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

else:

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

Submission status: Accepted

Solution code:
N = int(input())

D = sorted([int(v) for v in input().split()])
arc = N // 2
abc = arc - 1
print(D[arc] - D[abc])

Submission status: Accepted

Solution code:
n = int(input())
d = sorted(list(map(int, input().split())))
l = []
r = []
for elm in d:
  if len(l) < n / 2 or l[-1] == elm:
    l.append(elm)
  else:
    r.append(elm)

if len(l) != len(r):
  print(0)
else:
  ans = r[0] - l[-1]
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

D.sort()
#print(D)
s=D[(N//2)-1]
b=D[(N//2)]
#print(str(s)+' '+str(b))

K=b-s
print(K)

Submission status: Accepted

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

length = len(d)
length_half = int(length/2)


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

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()
med_i = int(len(d)/2)
print(d[med_i] - d[med_i - 1])

Submission status: Accepted

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




print(max(0, a[n//2] - a[n//2-1]))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

def main(N, d):
    d.sort()
    upper = N // 2
    lower = N // 2 -1
    ans = d[upper] - d[lower]
    return ans

if __name__ == '__main__':
    N = int(input())
    d = list(map(int, input().split()))
    print(main(N, d))

Submission status: Accepted

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

print(d)

Submission status: Accepted

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

E = sorted(D)

if N%2 == 0:
    a = E[N//2-1]
    b = E[N//2]
    
    answer = b - a
else:
    answer = 0
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 = [int(i) for i in input().split()]
k = [0]*100010
for i in d:
    k[i] += 1

for i in range(100010):
    k[i] += k[i-1]

#print(k[:10])
print(k.count(N//2))

Submission status: Accepted

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

nums.sort()

if n%2==1:
    print(0)
else:
    x=int((n/2)-1)
    y=int(n/2)
    a=nums[x]
    b=nums[y]
    s=b-a
    print(s)

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()))
l.sort()
print(l[int(n/2)]-l[int(n/2)-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

arc_idx = len(xs)//2
k_upper = xs[arc_idx]
k_lower = xs[arc_idx - 1] + 1

print(max(k_upper - k_lower + 1, 0))

Submission status: Accepted

Solution code:
max = int(raw_input())
#nums = raw_input().split(" ")
nums = map(int, raw_input().split())
nums.sort()
#print nums
print nums[max/2] - nums[max/2-1]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = sorted([int(x) for x in input().split(' ')])
if d[int(n/2)-1] == d[int(n/2)]:
    print(0)
else:
    print(d[int(n/2)] - d[int(n/2)-1])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
temp=input().split()
d=[int(temp[i]) for i in range(N)]
d.sort()
  
a=d[int(N/2-1)]
b=d[int(N/2)]
print(int(b-a))

Submission status: Accepted

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

ds.sort()

small = ds[N//2-1]
big = ds[N//2]

print(big - small)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
b=sorted(a)
if b[int(n/2)]!=b[int(n/2)-1]:
    ans=b[int((n/2))]-b[int(n/2)-1]
else:
    ans=0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def check(N, d):
    numList = d
    numList.sort()
    
    if N % 2 != 0:
        print(0)
    else:
        print(numList[int(len(numList)/2)] - numList[int(len(numList)/2-1)])

N = int(input())
d = [int(i) for i in input().split()]
check(N, d)

Submission status: Accepted

Solution code:
def check():
    N = int(input())
    numList = list(map(int, input().split(" ")))
    numList.sort()
    
    if N % 2 != 0:
        print(0)
    else:
        print(numList[int(len(numList)/2)] - numList[int(len(numList)/2-1)])

check()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = int(input())
x = list(map(int, input().split()))

a=sorted(x)
h=A//2

kotae=a[h]-a[h-1]
print(kotae)

Submission status: Accepted

Solution code:

N = int(input())
values = sorted([int(i) for i in input().split()])
length = len(values)
mode_diff = values[length//2] - values[length//2 -1]
print(mode_diff)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

sorted_data = sorted(d)
lower_bd = N // 2 - 1
upper_bd = N // 2
print(sorted_data[upper_bd] - sorted_data[lower_bd])

Submission status: Accepted

Solution code:
import  numpy   as      np

i_N             =       int(input())
s_d               =       input().split()
i_d             =       np.array(s_d).astype(type(i_N))
i_Counter       =       0
i_d             =       sorted(i_d)

if(i_d[int(len(i_d)/2)-1] < i_d[int(len(i_d)/2)]):
        i_Counter       =       i_d[int(len(i_d)/2)] - i_d[int(len(i_d)/2)-1]
print(i_Counter)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    d = [int(a) for a in input().split()]
    d_sort = sorted(d)
    if (d_sort[N//2-1] == d_sort[N//2]):
        print(0)
    else:
        print(d_sort[N//2]-d_sort[N//2-1])

main()

Submission status: Accepted

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

if N % 2 == 0:
    middle = N // 2
    if A[middle-1] == A[middle]:
        print("0")
    else:
        print(str(A[middle]-A[middle-1]))
else:
    print("0")

Submission status: Accepted

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


def solve(ds):
    ds = sorted(ds)
    imid = len(ds)//2
    abc_max = ds[imid-1]
    arc_min = ds[imid]

    return arc_min - abc_max


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()

if d[n//2-1] == d[n//2]:
    cnt = 0
else:
    cnt = d[n//2] - d[n//2-1]

print(cnt)

Submission status: Accepted

Solution code:
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#s[i] is linked with t[len(s)-i-1]
def main():
	n = int(input())
	d = list(map(int,input().split()))
	d.sort()
	print(max(d[n//2] - d[n//2-1],0))


def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Submission status: Accepted

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

def main():
	n = int(input().strip())
	v = list(map(int, input().strip().split()))
	ans = 0
	if len(v) % 2 == 0:
		t = sorted(v)
		ans = t[n//2] - t[n//2 - 1]
	print(ans)

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

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 = [int(_) for _ in input().split()]

d.sort()

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

ans = d_r - d_l
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# -*- coding: utf-8 -*-


from sys import stdin



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

# read data for n sequences.
temp = stdin.readline().split()
N = int(temp[0])

data = []
write = stdin.readline().split()
for i in range(N):
    data.append(int(write[i]))

data = sorted(data)

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc132/tasks/abc132_c
# C - Divide the Problems

n = int(input().split()[0])
d_list = list(map(int, input().split()))

sorted_d_list = sorted(d_list)

if sorted_d_list[int(n/2)-1] == sorted_d_list[int(n/2)]:
    ans = 0
else:
    abc_max = sorted_d_list[int(n/2)-1]
    arc_min = sorted_d_list[int(n/2)]
    k_min = abc_max + 1
    k_max = arc_min

    ans = k_max - k_min + 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())
a=[int(i) for i in input().split()]
a.sort()
print(a[int(n/2)]-a[int(n/2)-1])

Submission status: Accepted

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

sorted_d = sorted(d)
half = n//2

a = sorted_d[half-1]
b = sorted_d[half]

print(b-a)

Submission status: Accepted

Solution code:
n = int(input())
lis = list(map(int, input().split()))
lis2 = sorted(lis)
m1 = lis2[n//2-1]
m2 = lis2[n//2]

c = 0
for i in range((m1+1), (m2+1)):
    c += 1
print(c)

Submission status: Accepted

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


def solve(N: int, d: "List[int]"):
    d = sorted(d)
    dl = d[:N//2]
    du = d[N//2:]
    print(du[0] - dl[-1])
    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
A = [int(a) for a in input().split()]
A.sort(reverse=False)
len = n //2
print(A[len] - A[len-1])

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

d.sort()
#print(d)
center = int(n / 2)

diff = d[center] - d[center-1]

print(diff)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
d = sorted(d)
k = 0
import math
if n % 2 == 0 and d[math.floor((n-1)/2)] != d[math.ceil((n-1)/2)]:
    k = d[math.ceil((n-1)/2)] - d[math.floor((n-1)/2)]
elif n % 2 == 1 and d[(n-1)/2] != d[(n-1)/2 -1] and d[(n-1)/2] != d[(n-1)/2 + 1]:
    k = 1
else:
    k = 0
    
print(k)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

dn1=sorted(dn,reverse=True)
dnlen=int(len(dn)/2)
if dn1[dnlen-1] == dn1[dnlen]:
    print(0)
else:
    print(dn1[dnlen -1]-dn1[dnlen])

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = b - a
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

S = input()

N = int(S)

S = input()

D = list(map(int, S.split()))

D = sorted(D)

length = len(D)

length_half = length / 2

print(D[int(length_half)]-D[int(length_half-1)])

Submission status: Accepted

Solution code:
#基数ソート
def BinarySort(N, d, index):
  if index > 0:
    d = BinarySort(N, d, index-1)

  count = [0]*10

  num = []

  for di in d:
    num.append( di // (10**index) % 10)
    count[num[-1]] +=1

  for i in range(9):
    count[i+1] += count[i]
  d_ = [None]*N

  for i in range(N-1, -1, -1):
    count[num[i]] -= 1
    d_[ count[num[i]] ] = d[i]
  #print(d_)
  return d_

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

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

if d[-1+b]<d[b]:
    print(d[b]-d[b-1])
else:
    print(0)

Submission status: Accepted

Solution code:
#整数Nを得る
N = int(input())
#list  Pを得る
d = list(map(int,input().split()))

d.sort()

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

print(Ans)

Submission status: Accepted

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

d.sort()

mod = N // 2
ans = d[mod] - d[mod-1]

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
from bisect import bisect

N = int(input())
inputs = sorted([int(i) for i in input().split()])

ans = 0
for i in range(inputs[-1] + 1):
    index = bisect(inputs, i)
    if index == (N // 2):
        ans += 1
    elif index > (N // 2):
        break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
d = 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())
d = [int(i) for i in input().split()]

d.sort()

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

if (r-l > 0) :
    print(r-l)
else :
    print(0)

Submission status: Accepted

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

if __name__ == "__main__":
    C_DividetheProblems()

Submission status: Accepted

Solution code:
a=int(input())
inp = [int(x) for x in input().split()]
inp.sort()
med=int(len(inp)/2)
print(inp[med]-inp[med-1])

Submission status: Accepted

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

a.sort()

m = n // 2
print(a[m] - a[m-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]
if ans < 0:
  ans = 0

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
k = 0
a = sorted(a)
maxa = a[int(len(a)/2)]
mina = a[int(len(a)/2)-1]+1
if mina > maxa:
    print(0)
else:
    print(maxa-mina+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()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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