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

a = A[int(N/2 - 1)]
b = A[int(N/2)]

print(b-a)

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
D = LI()

D = sorted(D)

mid = len(D)//2
# 周辺だけチェックする
if D[mid-1] == D[mid]:
    # 同じ数字が中間であるので、無理
    print(0)
    exit()
else:
    res = D[mid] - D[mid-1]
    print(res)

Submission status: Accepted

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

P=sorted(p)

K=P[n//2]-P[n//2-1]

print(K)

Submission status: Accepted

Solution code:
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


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


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
14
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1
'''

def MAIN():
  # T_IN()
  A()


def A():
  num = IN_I()
  lists = IN_L_I()
  lists.sort()

  print(lists[num // 2] - lists[num // 2 - 1])
  return None


def B():
  return None


def C():
  return None


MAIN()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

def main():
    N = int(input())
    difficulty_list = list(map(int, input().split(" ")))
    big_list = sorted(difficulty_list, reverse=True)
    index = int(N/2)
    upper = big_list[index-1]
    lower = big_list[-index]
    count = upper - lower
    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

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:
def main06():
    num = int(input())
    data = input().split()
    zyun = []
    for i in data:
        zyun.append(int(i))
    zyun.sort()
    naka = int(num/2)
    result = zyun[naka] - zyun[naka-1]
    print(result)
    
if __name__ == "__main__":
    main06()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

N = int(input())
D = list(map(int,input().split()))
D = sorted(D)
left = D[int(N/2)-1]
right = D[int(N/2)]
if left == right:
    print(0)
else:
    print(right-left)

Submission status: Accepted

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

d.sort()
print(d[i] - d[i - 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()

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:
    print(abs(d[0]-d[1]))
else:
    d.sort()
    mid = int(N/2)
    print(d[mid]-d[mid-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=int(input())
b=list(map(int,input().split()))
b=sorted((b)[::-1])

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

lst_d.sort()
l = int(len(lst_d) / 2)

low = lst_d[l - 1]
upp = lst_d[l]

print(upp - low)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

def solve():
    N = int(input())
    D = list(map(int, input().split()))
    D.sort()

    i = N//2

    if D[i] == D[i-1]:
        print(0)
        return
    
    print(D[i]-D[i-1])

if __name__ == "__main__":
    solve()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

d = sorted(d)

div = len(d)//2 - 1

print(d[div+1] - d[div])

Submission status: Accepted

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

d = sorted(d)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
a.sort()
center = len(a) // 2
cnt = 0
for i in range(1, 10 ** 5 + 1):
    if a[center - 1] < i <= a[center]:
        cnt += 1
print(cnt)

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

L = sorted(L)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
mid = int(int(input())/2)
problems = sorted(list(map(int, input().split())))
if not len(problems) % 2:
    print(problems[mid] - problems[mid-1])
else:
    print(0)

Submission status: Accepted

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

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

    D.sort()

    i = N//2

    if D[i] != D[i-1]:
        print(D[i]-D[i-1])
        return
    print(0)

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

a.sort()
k = int(n/2)    
print(a[k]-a[k-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

sort_li = sorted(li)


n = int(int(N)/2)

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

Submission status: Accepted

Solution code:
n = int(input())

d = []
s = input().split()
sum = 0
for i in range(n):
  d.append(int(s[i]))
  sum += int(s[i])

d.sort()

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

li.sort()
a = li[int(len(li)/2-1)]
b = li[int(len(li)/2 )]

print(b-a)

Submission status: Accepted

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

Submission status: Accepted

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

dif.sort()

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

print(ans)

Submission status: Accepted

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

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

    D.sort()
    i = N//2

    if D[i] != D[i-1]:
        # 同じ数になるように分けることが可能
        print(D[i]-D[i-1])
        return
    print(0)
    

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
a = int(input())
b = list(map(int, input().split()))
b.sort()
for i in range(a//2, a):
    print(b[i]-b[i-1])
    exit()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


def count_choices(n, nums):
    if n & 1 == 1:
        return 0

    nums.sort()

    mid = n // 2

    if nums[mid] == nums[mid - 1]:
        return 0

    return nums[mid] - nums[mid - 1]


def main():
    n = int(input())
    nums = list(map(int, input().split()))

    ans = count_choices(n, nums)
    print(ans)


main()

Submission status: Accepted

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

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

print(b-a)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

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

d.sort()
num = int(len(d) / 2)
ans = d[num ] - d[num-1]
#print(d)
#print(d[num],d[num+1])
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
""" 
d = [9, 1, 4, 4, 6, 7]
#N = 8
N = 6
#d = [9, 1, 14, 5, 5, 4, 4, 14]
d = [9, 1, 4, 4, 6, 7]
 """
# prob
# [number,value]
prob = []
cnt = 0
for i in d:
    prob.append([cnt, i])
    cnt += 1

""" print(prob)
print(sorted(prob, key=lambda x: x[1]))
 """
sorted_d = sorted(prob, key=lambda x: x[1])

#print(d_min, d_max)
cnt = 0
# if len(sorted_d[0:i]) == len(sorted_d[i:]):
cnt += sorted_d[int(N/2)][1] - sorted_d[int(N/2-1)][1]

print(cnt)

Submission status: Accepted

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

d = sorted(d)

former = d[:eval(str(int(len(d) / 2)))]
latter = d[eval(str(int(len(d) / 2))):]

if former[-1] == latter[0]:
  print(0)
else:
  print(latter[0] - former[-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
d = list(int(x) for x in input().split())

d.sort()

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

Submission status: Accepted

Solution code:
N = int(input())
d = [int(i) for i in input().split()]
d = sorted(d)
low_num = d[int(N/2) - 1]
up_num = d[int(N/2)]
answer = 0
if(low_num == up_num):
    answer = 0
else:
    answer = up_num - low_num
print(answer)

Submission status: Accepted

Solution code:
def main():
  n = int(input())
  d = list(map(int,input().split()))
  ans = 0 
  d.sort()# distructive sort of list d
  if d[n//2 -1] != d[n//2]:
    ans = d[n//2] -d[n//2 -1] 
  print(ans)
main()

Submission status: Accepted

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

d.sort()
minIndex = len(d) / 2 - 1
maxIndex = len(d) / 2

dmin = d[int(minIndex)]
dmax = d[int(maxIndex)]

print(dmax - dmin)

Submission status: Accepted

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

ARC_min = d_lis[int(N/2)]
ABC_max = d_lis[int(N/2)-1]

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

Submission status: Accepted

Solution code:
n = int(input())
count=0

nums = list(map(int, input().split()))
nums.sort()
n/=2

if nums[int(n)] == nums[int(n-1)]:
    print(0)
else:
    print(int(nums[int(n)]-nums[int(n-1)]))

Submission status: Accepted

Solution code:
import statistics

n = int(input())
d = list(map(lambda x: int(x), input().split()))
m = statistics.median(d)
s = [i for i in d if i < m]
b = [i for i in d if i >= m]

if len(s) == len(b):
    ans = min(b) - max(s)
else:
    ans = 0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

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

print(d_right - d_left)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
lower, upper = N//2-1, N//2
D = [int(_) for _ in stdin.readline().rstrip().split()]
D.sort()
print(D[upper]-D[lower])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# C - Divide the Problems

N = int(input())
data = list(map(int, input().split()))
data.sort()

half = int(N / 2)

print(data[half] - data[half-1])

Submission status: Accepted

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

h=int(n/2)
k_min=d[h-1]
k_max=d[h]
print(k_max-k_min)

Submission status: Accepted

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

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

arr.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

ans = data[N//2] - data[N//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:
N = int(input())
D = [int(i) for i in input().split()]

D_unique = list(set(D))
D.sort()

middle_idx = int(len(D)/2)
cnt = D[middle_idx]-D[middle_idx-1]
    
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
d.sort(key=int)
print(abs(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()

r = d[n//2]
l = d[n//2-1]

print(r-l)

Submission status: Accepted

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

Submission status: Accepted

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

n.sort()

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

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

Submission status: Accepted

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

list3=sorted(list2)

Y=list3[int(N/2)]-list3[int(N/2-1)]
print(Y)

Submission status: Accepted

Solution code:
N = int(input())
d_ = input().split(" ")

d = []


for i in range(N):
    d.append( int(d_[i]))

d.sort()

midNum = int(N/2)



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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import random
import numpy as np

N = int(input())
d = [int(i) for i in input().split()]
dd = np.sort(d,kind='quicksort')

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

K = dd[a] - dd[b]

print(K)

Submission status: Accepted

Solution code:
# encoding: utf-8
import sys
# input = sys.stdin.readline

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

d.sort()

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

Submission status: Accepted

Solution code:
# how many ways can diveide "K"
n = input()
arr = [int(x) for x in input().split()]
arr.sort()
l = len(arr)
ans = 0
if l%2 == 0:
	if arr[l//2] != arr[l//2-1]:
		ans = (arr[l//2] - arr[l//2 -1])
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
difficulty = map(lambda x:int(x) ,input().strip().split())

probrems = []

for d in difficulty:
    probrems.append(d)


probrems.sort()

p_n = probrems[int(n/2)-1]
p_n_1 = probrems[int(n/2)]

print(p_n_1 - p_n)

Submission status: Accepted

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

B.sort()
cnt = 0
C = 0
result = 0
D = A // 2
for i in B:
    if cnt == D:
        result = i - C
        break
    else:
        C = i
        cnt += 1

print(result)

Submission status: Accepted

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

B.sort()
cnt = 0
C = 0
result = 0
for i in B:
    if cnt == A // 2:
        result = i - C
        break
    else:
        C = i
        cnt += 1

print(result)

Submission status: Accepted

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

p.sort()

ans = 0
mid = int(n/2)

if p[mid] != p[mid-1]:
    ans = p[mid] - p[mid-1]

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    nums = string_to_int(inputs[0])
    nums.sort()
    abc_last_i = len(nums) // 2 - 1
    arc_first_i = len(nums) // 2

    return nums[arc_first_i] - nums[abc_last_i]


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

Solution code:
N = int(input())


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

ls.sort()

K = ls[N//2] - ls[N//2 - 1]

print(int(K))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import statistics as stat

def calc(p):
  p.sort()
  l = len(p)
  return p[(l + 1) // 2] - p[(l - 1) // 2]

_ = input()
p = list(map(int, input().split()))

print(calc(p))

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

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 = [int(i) for i in input().split()]
sorted_d = sorted(d)
center = sorted_d[int(n/2)]
if sorted_d[int(n/2-1)] == center:
    ans = 0
else:
    ans = center - sorted_d[int(n/2-1)]
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

D.sort()

mid = int(len(D)/2) -1
mid_next = D[mid+1] 
if D[mid] == D[mid + 1]:
    print(0)
else:
    for d in D[mid:len(D)]:
        if D[mid] != d:
            mid_next = d
            break
    print(mid_next - D[mid])

Submission status: Accepted

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

d.sort()
cnt=0
m=N//2
cnt=d[m]-d[m-1]
print(cnt)

Submission status: Accepted

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

d_list = sorted(d_list)

left = d_list[N//2 - 1]
right = d_list[N//2 ]

if right - left > 0:
	print(right-left)
else:
 	print(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def count_ABC_num(D, thr):
    return len([_ for _ in D if _ < thr])

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

D.sort()
cent_index = int(len(D)/2)

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

Submission status: Accepted

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

ret=Nlist[int(N/2)]-Nlist[int(N/2)-1]

print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=int(input())
L=sorted(map(int,input().split()))
if L[S//2-1] != L[S//2]:
  print(L[S//2] - L[S//2-1])
else:
  print(0)

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())

d = [int(x) for x in input().split()]
d = np.array(d)

d = np.sort(d)

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

Submission status: Accepted

Solution code:
import sys


scan = sys.stdin.readline


def main():
  n = int(scan().rstrip())
  d = [int(_) for _ in scan().rstrip().split()]
  
  if n % 2 == 1:
    print(0)
    sys.exit(0)
  
  d.sort()
  
  mid_index = len(d) // 2
  
  mid_small = d[mid_index - 1]
  mid_big = d[mid_index]
  
  print(mid_big - mid_small)


if __name__ == "__main__":
  main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
input = sys.stdin.readline

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


sd = sorted(d)
h = int(len(sd)/2)
result = sd[h] - sd[h-1]

print(result)

Submission status: Accepted

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

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

Submission status: Accepted

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

mi = d[int(len(d)/2-1)]
ma = d[int(len(d)/2)]

print(ma-mi)

Submission status: Accepted

Solution code:
N = int(input())
D = [int(d) for d in input().split()]
D.sort()
D_small = D[0:N//2]
D_big = D[N//2:N]
if D_small[-1]==D_big[0]:
  ans = 0
else:
  ans = D_big[0] - D_small[-1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

d_list.sort()

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

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
d.sort()
cs = [0]
ans = 0
l= 0
for i in range(d[-1]):
  temp = 0
  while(True):
    if i == d[l]:
      temp += 1
      l += 1
    else:
      break

  cs.append(cs[i]+temp)

ans = cs.count(n/2)
print(ans)

Submission status: Accepted

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


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

Submission status: Accepted

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

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

Submission status: Accepted

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