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 = [int(i) for i in input().split()] 
D.sort()
M = int(N/2)
S = 0

if D[M] == D[M-1]:
	print(0)
else:
	print(D[M] - D[M-1])

Submission status: Accepted

Solution code:

n = int(input())
harf = int(n/2)
d_list = list(map(int, input().split()))

d_sorted = sorted(d_list)

ans = int(d_sorted[harf]-d_sorted[harf-1])

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

d.sort()

a = int(int(n)/2-1)
b = int(int(n)/2)

if d[b] - d[a] > 0:
  print(d[b]-d[a])
else:
  print("0")

Submission status: Accepted

Solution code:
N=int(input())
a=list(input().split())
for i in range(N):
    a[i]=int(a[i])
a.sort()
num1=a[N//2-1]
num2=a[N//2]
ans=num2-num1
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
n = input()
n = int(n)
data = input().split()
data = np.array(data)
data = data.astype(int)
data = np.sort(np.array(data))

low = data[n/2 - 1]
high = data[n/2]
print(high - low)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

D = sorted(D)

a = D[int(n/2-1)]
b = D[int(n/2)]

print(len(list(range(a+1, b+1))))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

qlist.sort()

print(qlist[n//2] - qlist[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:
# coding: utf-8

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

problems.sort()


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

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
max_k = max(d)
min_k = min(d)
d.sort()
half = N // 2
print(d[half] - d[half - 1])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np

N = int(input())
d = np.array(list(map(int, input().split())))
d = np.sort(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()
m1, m2 = d[int(N/2)-1], d[int(N/2)]
if m1 == m2:
    print(0)
    exit()
else:
    print(m2-m1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
ls = list(map(int,input().split(" ")))
ls.sort()
num = n//2 - 1
max = max(ls)
ans = 0
if (len(ls) >= 2):
  ans = ls[num+1] - ls[num]
print(ans)

Submission status: Accepted

Solution code:
s = int(input())
n = list(map(int,input().split()))
S = []
count=0
a = len(n)//2
n.sort()

for i in range(n[a-1],n[a]):
    count+=1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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


r = N // 2
l = r - 1

print(d_list[r] - d_list[l])

Submission status: Accepted

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

a = sorted(d)
b = n // 2

ans = a[b] - a[b-1]
print(ans)

Submission status: Accepted

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

if len(list) % 2 != 0:
    print(0)
else:
    print(list[int(len(list) / 2)] - list[int((len(list) /2) - 1)])

Submission status: Accepted

Solution code:
K=int(input())
D=[int(x) for x in input().split()]
D.sort()
M=K/2
m=M-1
ans=D[int(M)]-D[int(m)]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# divide the problem
n = int(input())
list = [int(i) for i in input().split(' ')]
list.sort()
# print(list)
a = list[int(n/2-1)]
b = list[int(n/2)]
print(b-a)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
num = int(input())
difficulty = [int(i) for i in input().split()]
difficulty.sort()
K = 0
if difficulty[int(num/2)] != difficulty[int(num/2 - 1)]:
    K = difficulty[int(num/2)] - difficulty[int(num/2 - 1)]
else:
    K = 0
print (K)

Submission status: Accepted

Solution code:
import collections

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

c = collections.Counter(D)
c = sorted(c.items(), key=lambda x:x[0])

rates, counter = list(zip(*c))

acc = 0
found = False
for i in range(len(counter)):
    acc += counter[i]
    if acc == N/2:
        found = True
        break
    if acc > N/2:
        found = False
        break

if found == False:
    print(0)
else:
    print(rates[i+1]-rates[i])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split(" ")))
a = 0
p.sort()
n_2 = int(n / 2)
abc = p[:n_2]
arc = p[n_2:]
a = arc[0] - (abc[len(abc) - 1]) 
print(a)

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
lst = [i for i in map(int, input().split())]
if N % 2 != 0:
    print(0)
else:
    lst = sorted(lst)
    print(lst[N//2] - lst[N//2-1])

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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=int(input())
d=list(map(int, input().split()))
d.sort()
arc_start_index = N // 2

ABC_max = d[arc_start_index-1]
ARC_min = d[arc_start_index]

if ABC_max == ARC_min:
    print(0)
else:
    print(ARC_min - ABC_max)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
p = [int(i) for i in input().split()]
p.sort()
m = int(N/2)
if p[m-1]==p[m]:
  print(0)
else:
  print(p[m]-p[m-1])

Submission status: Accepted

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

C=int(N/2)-1

if d[C]!=d[C+1]:
    print(d[C+1] - d[C])
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
num = int(input())
seq = input().split()

sequence = sorted([int(i) for i in seq])
a, b = len(sequence)//2-1,  len(sequence)//2

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

Submission status: Accepted

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

if d[N // 2 - 1] != d[N // 2]:
    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()))

under = 0
uper = 0
ans = 0
d.sort()
n = int(N/2)
min = d[n-1]
mid = d[n]

low = [i for i in d if i < d[n-1]]
hi = [i for i in d if i >= d[n-1]]
if len(low) == len(hi):
    under = 1

low = [i for i in d if i < d[n]]
hi = [i for i in d if i >= d[n]]
if len(low) == len(hi):
    uper = 1

ans = d[n] - d[n-1] - 1 + under + uper
if ans < 0:
    ans = 0
print(ans)

Submission status: Accepted

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

d_list.sort()
mid = int(N/2)

dif = d_list[mid] - d_list[mid - 1]

print(dif)

Submission status: Accepted

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

li.sort()

div = li[int((n / 2))] - li[int(n / 2) - 1]

print(div)

Submission status: Accepted

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

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

Submission status: Accepted

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

def main():
    n=int(input())
    d = list(map(int,input().split()))
    cnt=0

    d.sort()
    a=d[(n//2)-1]
    b=d[(n//2)]
    ans=b-a
    print(ans)
    
main()

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

Submission status: Accepted

Solution code:
N = int(input())
levels = list(map(int, input().split()))
#print(levels)
levels.sort()
#print(levels)

divid_number = int(N/2)
#print(levels[divid_number-1])
#print(levels[divid_number])
print(levels[divid_number]-levels[divid_number-1])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
l = sorted([int(x) for x in input().split()])
mid = int(len(l) / 2)
med = int((l[mid-1] + l[mid]) / 2)
if l[mid] != l[mid-1]:
    print(l[mid] - l[mid-1])
else:
    print(0)

Submission status: Accepted

Solution code:
import statistics

n=int(input())
list1 = list(map(int, input().split()))
cnt = 0
ans=[]
av = statistics.median(list1)
for i in range(n):
    ans.append(abs(list1[i]-av))

fir=min(ans) 
sec=sorted(ans)[1]

print(int(fir+sec))

Submission status: Accepted

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

n = int(input())
d = input().split(" ")

d_ = [int(s) for s in d]

d_.sort()
cen = int(n/2)
num = d_[cen]-d_[cen-1]
print(str(num))

Submission status: Accepted

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

dk = d[N//2-1]

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

Submission status: Accepted

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

d.sort()

c=0
if d[N//2] == d[N//2-1]:
    print(0)
else:
    K=d[N//2-1]+1
    while K <= d[N//2]:
        K+=1
        c+=1

    print(c)

Submission status: Accepted

Solution code:
import numpy as np
def resolve():
    N = int(input())
    d = [int(i) for i in input().split()]
    d = np.array(d)
    d = np.sort(d)
    print(d[N // 2] - d[N // 2 - 1])
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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


D.sort()

upDindex = len(D)//2
lowDindex = (len(D)//2)-1


Upper = D[upDindex]
Lower = D[lowDindex]

count = Upper-Lower


print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from itertools import accumulate

input = sys.stdin.readline


def main():
    n = int(input())
    d_list = sorted([int(i) for i in input().split()])
    print(d_list[n // 2] - d_list[n // 2 - 1])
    # print(list(accumulate(d_list, max)))
    # K 選び方でARC と ABCが同じ数になる選び当た


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

M = N//2

x,y = D[M-1:M+1]
answer = y - x
print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import statistics
n = int(input())
d = input().split(' ')
d = [int(i) for i in d]
m = int(statistics.median(d))
nn = int(n/2) 
d.sort()
print(d[nn] - d[nn-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:

n = int(input())

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

d = sorted(d)

ans =  d[(n//2)] - d[(n//2)-1] 

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    input()
    a = list(map(int, input().split()))
    sort_a = sorted(a)
    middle = int(len(a)/2)
    count = sort_a[middle] - sort_a[middle-1]
    print(count)

Submission status: Accepted

Solution code:
# coding=utf-8

###
### for atcorder program
###

import sys
import math
import array

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def main():
    
    N = int(input())
    D = [int(w) for w in input().split()]

    D.sort()

    print(D[(N//2)] - D[N//2-1])
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
d = 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 = [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())
ds = input().split()
ds = [int(i) for i in ds]
ds.sort()
#print(ds)
#if ds[int(N/2)] == ds[int(N/2)+1]:
#  print("0")
#else:
print(ds[int(N/2)]-ds[int(N/2)-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n = input()
lists = [int(i) for i in input().split()]
list.sort(lists)

mid = math.floor((len(lists))/2)
mnnaka = lists[mid]
ikkosita = lists[mid-1]

if(mnnaka==ikkosita):
    print(0)
else:
    print(mnnaka-ikkosita)

Submission status: Accepted

Solution code:
import sys
inputs = sys.stdin.readlines()
N = int(inputs[0])
d = [int(x) for x in inputs[1].split(' ')]
d.sort()

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

Submission status: Accepted

Solution code:
n=int(input())

arr=[int(i) for i in input().split()]

arr.sort()
i=int(n/2)

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

Submission status: Accepted

Solution code:
N = int(input()) 
d = list(map(int, input().split()))
a=int(N/2)
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    # データの状態に左右されないためにrandom.choice()を用いることもある。
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right
d=quick_sort(d)
print(d[a]-d[a-1])

Submission status: Accepted

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

D.sort()
num = int(N//2)
count = D[num]-D[num-1]
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
dd = list(map(int,input().split()))
dd.sort()
# print(dd)
fir = dd[len(dd)//2-1]
sec = dd[len(dd)//2]
cou = 0
i = fir + 1
# print(fir,sec)
# while i <= sec:
#     cou += 1
#     i += 1
print(sec-i +1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def divide_the_problems(N: int, D: list)->int:
    D.sort()
    return D[N//2]-D[N//2-1]


if __name__ == "__main__":
    N = int(input())
    D = [int(s) for s in input().split()]

    ans = divide_the_problems(N, D)
    print(ans)

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

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

A_sorted = sorted(A)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# C
if __name__=='__main__':
    n = int(input())
    m = int(n/2)
    d = [int(x) for x in input().split()]
    d.sort()
    print(d[m]-d[m-1])

Submission status: Accepted

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

left = l[int(N / 2) - 1]
right = l[int(N / 2)]

ans = right - left

print(ans)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    ds = input().split()
    if n % 2:
        print(0)
        return

    nds = sorted(list(map(lambda x: int(x), ds)))
    print(nds[n//2] - nds[(n//2)-1])


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

d.sort()
print(d[CEN]-d[CEN-1])

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

Solution code:
import sys


def main():
    n = int(sys.stdin.readline().strip())
    ds = sys.stdin.readline().strip()
    d = [int(s) for s in ds.split()]
    sorted_d = sorted(d)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#C
N= map(int, input().split())
d = list(map(int, input().split()))
sort_d =sorted(d)
len_d = len(d)
half_low = int(len_d/2-1)
half_up = int(len_d/2)
ans =sort_d[half_up]-sort_d[half_low]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input())

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

B = sorted(list_A)
half = int(num/2)
left = B[half-1]
right = B[half]
if left == right:
    ans = 0
else:
    ans = right-left

print(ans)

Submission status: Accepted

Solution code:
num = int(input())
array = list(map(int, input().split()))

sort_list = sorted(array)
num_ha = int(num /2)

print(sort_list[num_ha]-sort_list[num_ha -1])

Submission status: Accepted

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

ans = 0

#for k in range(min(l)+1, max(l)):
#    l_abc = [i for i in l if i < k]
#    l_arc = [i for i in l if i >= k]
#    if len(l_abc) == len(l_arc):
#        ans += 1
        
l_s = sorted(l)
diff = l_s[int(len(l_s)/2)] - l_s[int(len(l_s)/2)-1]
if diff > 0:
    print(diff)
else:
    print(0)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
d.sort()
k_count = 0
i = n // 2 - 1
arc = len(list(filter(lambda x: x > d[i], d)))
abc = len(list(filter(lambda x: x <= d[i], d)))
if arc == abc:
    k_count += (d[i+1] - d[i])
print(k_count)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = [int(x) for x 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_sorted = sorted(d)

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

#print(d_sorted)
#print(d_sorted[int(n/2)], d_sorted[int(n/2)-1])

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    D = sorted(list(map(int, input().split())))
    idx = len(D) // 2
    mid = D[idx]
    low = D[idx - 1]
    if mid == low:
        print(0)
        return

    print(mid - low)

resolve()

Submission status: Accepted

Solution code:
import re
import numpy as np


N = int(input())
ds= np.array([int(i) for i in input().split()] )

ds2=np.sort(ds)
print(ds2[N/2]-ds2[N/2-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
s = sorted(d)
half = N//2
answer = s[half-1] #ABC最難関
count = 0
i = 0
while answer + i <= s[half]:
  count += 1
  i += 1
print(count-1)

Submission status: Accepted

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


m = sorted(l)
if len(m)%2!=0:
    print(0)
else:
    i = len(m)//2 -1
    ans = m[i+1]-m[i]
    print(ans)

Submission status: Accepted

Solution code:
import math

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

center=int((n/2)-1)
print(sorted_d[center+1]-sorted_d[center])

Submission status: Accepted

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

numbers = sorted(numbers)

diff_half_n = numbers[int(n/2)-1]
diff_half_n_plus_1 = numbers[int(n/2)]

print(diff_half_n_plus_1 - diff_half_n)

Submission status: Accepted

Solution code:
N = int(input())
a = input()
k = 0
list1 = list(map(int,a.split()))

list1.sort()

k = list1[int(N/2)] - list1[int(N/2)-1] 
print(k)

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#n=int(input())
#import fractions
#import itertools
#import math
#lis=list(input().split())
#lis=list(map(float,input().split()))
#S=input()

n=int(input())
lis=list(map(int,input().split()))
lis.sort()
half=int(n/2)
a=lis[half-1]
b=lis[half]
delta=b-a
ans=delta

print(ans)

Submission status: Accepted

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

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())
t=input().split()
d=[]
for i in range(n):
    d.append(int(t[i]))

d.sort()

cut = int(n/2)

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

Submission status: Accepted

Solution code:
N = int(input())

d = input().split(" ")
for i, dd in enumerate(d):
    d[i] = int(dd)

d_sort = sorted(d) 

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

Submission status: Accepted

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

c = sorted(b)

i = int(len(c) / 2)

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

Submission status: Accepted

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

def main():
    # # 整数の入力
    # a = int(input())
    # # スペース区切りの整数の入力
    # b, c = map(int, input().split())
    # # 文字列の入力
    # s = input()
    # # 出力
    # print("{} {}".format(a+b+c, s))
    N = int(input())
    d_list = list(map(int, input().split()))
    sorted_d = sorted(d_list)
    print(sorted_d[N//2]-sorted_d[N//2-1])



if __name__=='__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

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

a_s = sorted(a)
half = N//2

upper = a_s[half]
under = a_s[half-1]

ans = upper - under

print(ans)