Problem:


Score : 300 points

Problem Statement

Takahashi made N problems for competitive programming.
The problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).

He is dividing the problems into two categories by choosing an integer K, as follows:

A problem with difficulty K or higher will be for ARCs.

A problem with difficulty lower than K will be for ABCs.

How many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?

Problem Statement

2 \leq N \leq 10^5

N is an even number.

1 \leq d_i \leq 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
d_1 d_2 ... d_N

Output

Print the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.

Sample Input 1

6
9 1 4 4 6 7

Sample Output 1

2

If we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.
Thus, the answer is 2.

Sample Input 2

8
9 1 14 5 5 4 4 14

Sample Output 2

0

There may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.

Sample Input 3

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

Sample Output 3

42685



Sample input:
6
9 1 4 4 6 7


Sample output:
2

Submission status: Accepted

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

def mergesort(a):
    def _merge_sort(a, left: int, right: int):
        if left < right:
            center = (left+right)//2

            _merge_sort(a,left,center)
            _merge_sort(a,center+1,right)

            #pは前半部をbuffにコピーする際のインデックス、jで取り出す
            p=j=0
            i=k=left

            #配列の前半部をbuffにコピー
            while i <= center:
                buff[p]=a[i]
                p+=1
                i+=1

            #後半部をコピーされた前半部と比較、小さい方をaに格納していく
            while i<= right and j < p:
                if buff[j] <= a[i]:
                    a[k]=buff[j]
                    j+=1
                else:
                    a[k]=a[i]
                    i+=1
                k+=1

            while j < p:
                a[k] =buff[j]
                k+=1
                j+=1

    n=len(a)
    #merge結果を一時的に格納
    buff=[None]*n
    _merge_sort(a,0,n-1)
    del buff

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

Submission status: Accepted

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

d.sort()

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    if n % 2 != 0:
        ans = 0
    else:
        mid = n // 2
        ans = ds[mid] - ds[mid-1]
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

l,r = D[N//2-1],D[N//2]
if l==r:
  print(0)
  exit()

print(r-l)

Submission status: Accepted

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

D.sort()

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
a = rl()
a.sort()
i = n//2
print(a[i] - a[i-1])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    d = sorted(map(int, input().split()))
    ans = d[N // 2] - d[N // 2 - 1]
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

d = sorted(d)

e = int(n/2-1)
f = int(n/2)


s = d[e]
t = d[f]
if s == t:
    print(0)
else:
    print(t-s)

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

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()

d_len = len(d)
d_center = d_len // 2

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

Submission status: Accepted

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

nums.sort()

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

Submission status: Accepted

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

half_ind = int(len(d)/2)
L = sorted(d)[half_ind-1]
R = sorted(d)[half_ind]

print(R - L)

Submission status: Accepted

Solution code:
N = int(input())
d_array = list(map(int, input().split()))
#小さい順に並べ替え
list.sort(d_array)
#真ん中の要素の差を取るとそれが答え
ans = d_array[N // 2] - d_array[N // 2 - 1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()
mind = d[n//2-1]
maxd = d[n//2]

ans = maxd - (mind + 1) + 1
if ans < 0:
    print(0)
    exit()
print(ans)

Submission status: Accepted

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

print(B-A)

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(ans)

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:
def resolve():
    N = int(input())
    d = list(map(int, input().split()))
    d.sort()
    ans = d[int(N / 2)] - d[int((N - 1) / 2)]
    if ans < 1:
        print(ans)
        return
    print(ans)
resolve()

Submission status: Accepted

Solution code:
# ans

import sys
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
d.sort()

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    d = list(map(int, input().split()))
    d.sort()
    
    center_left = N//2 - 1
    center_right = N//2
    ans = d[center_right] - d[center_left]
    print(ans)
main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

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

if lis[int(n/2)-1] == lis[int(n/2)]:
    print(0)
else:
    a = list(range(lis[int(n/2)-1]+1, lis[int(n/2)]+1))
    print(len(a))

Submission status: Accepted

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

Submission status: Accepted

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

mid1 = N // 2 - 1
mid2 = mid1 + 1
print(D[mid2] - D[mid1])

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    d = list(map(int, input().split()))
    d.sort()
    print(d[n // 2] - d[n // 2 - 1])


if __name__ == "__main__":
    setrecursionlimit(10000)
    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:
def solve(N,d):
  if N % 2 == 1:
    return 0
  else:
    arc = d[N//2:]
    abc = d[:N//2]
    return arc[0] - abc[-1]

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

print(solve(N,d))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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


left = d[tar]
right = d[tar + 1]
#print(left, right)
diff = right - left
if (diff == 0):
    ans = 0
else:
    ans = diff

print(ans)

Submission status: Accepted

Solution code:
# 初期入力
import sys
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
d.sort()
half_r =len(d)//2
half_l =len(d)//2 -1
ans =d[half_r] -d[half_l]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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:
# input
n = int(input())
qlist = [int(i) for i in input().split()]

# main
qlist.sort()
if qlist[n//2-1] == qlist[n//2]:
  print(0)
else:
  print(qlist[n//2]-qlist[n//2-1])

Submission status: Accepted

Solution code:
import itertools
import numpy as np

N = int(input())
points = np.array(list(map(int, input().split())))
ans = 0
s_points = sorted(points)

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(N: int, d: "List[int]"):
    half = int(len(d) / 2)
    d = sorted(d)
    bef = list(d[:half])
    aft = list(d[half:])
    ans = aft[0] - bef[len(bef) - 1]
    print(ans)
    return


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

# In[17]:


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


# In[18]:


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


# In[ ]:

Submission status: Accepted

Solution code:
N = int(input())

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

d.sort()

cnt = 0

for i in range(d[N//2-1]+1,d[N//2]+1):
    cnt+=1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

d.sort()

cnt = 0

for i in range(d[N//2-1]+1,d[N//2]+1):
    cnt+=1

print(cnt)

Submission status: Accepted

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

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:
def resolve():
    N  = int(input())
    D = list(map(int,input().split()))
    D.sort()
    print(D[int(N/2)] - D[int(N/2-1)])
resolve()

Submission status: Accepted

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

D.sort()

smallest_arc = D[N//2]
largest_abc = D[N//2 - 1]

print(smallest_arc - largest_abc)

Submission status: Accepted

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

D.sort()

smallest_arc = D[N//2]
largest_abc = D[N//2 - 1]

print(smallest_arc - largest_abc if smallest_arc != largest_abc else 0)

Submission status: Accepted

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

D = sorted(D)
left = D[N//2-1]
right = D[N//2]
# print("left: {}, right: {}".format(left, right))
print(right-left)

Submission status: Accepted

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

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

Submission status: Accepted

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

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


print(sa)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
'''
参考
https://drken1215.hatenablog.com/entry/2019/06/29/224100
dをソートし、d[N//2]-d[N//2-1]が解
'''
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()))

arc_list = list()
abc_list = list()

harf_num = int(n/2)

d.sort()
abc_list = d[:harf_num]
arc_list = d[harf_num:]

abc_max = max(abc_list)
arc_min = min(arc_list)

print(arc_min - abc_max)

Submission status: Accepted

Solution code:
#C
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,*a=map(int,open(0).read().split());a.sort()
print(a[n//2]-a[n//2-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
d.sort()
l=n//2-1
half=(d[l]+d[l+1])//2
count=0
sum=0
if d[l]==d[l+1]:
  print(0)
  exit()
sum+=d[l+1]-d[l]
print(sum)

Submission status: Accepted

Solution code:
N = int(input())

d = [0]*N
tmp = input().split()
for n in range(N):
    d[n]= int(tmp[n])

d.sort()

dm = d[N//2-1]
dM = d[N//2]

if dm == dM:
    print(0)
else:
    print(dM-dm)

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
d.sort()
l=n//2-1
half=(d[l]+d[l+1])//2
count=0
sum=0

if d[l]==d[l+1]:
  print(0)
  exit()

if d[l+1]>half:
  sum+=d[l+1]-half

if d[l]!=half:
  sum+=half-d[l]
  
print(sum)

Submission status: Accepted

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n = int(input())
    d_list = list(map(int, input().split()))
    d_list.sort()
    print(d_list[(n//2)] - d_list[(n//2)-1])

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

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

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()))
d2 = sorted(d.copy())
index = len(d2) // 2
if d2[index - 1] == d2[index]:
    print(0)
else:
    print(d2[index] - d2[index - 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()))
sort_d = sorted(d)
#print(sort_d)
middle = n // 2
a = sort_d[:middle]
b = sort_d[middle:]
print(sort_d[middle]-sort_d[middle-1])

Submission status: Accepted

Solution code:
n = int(input())
d = sorted(list(map(int, input().split())))
h = int(len(d) / 2)
ans = 0

if d[h-1] != d[h]:
    ans = d[h] - d[h-1]

print(ans)

Submission status: Accepted

Solution code:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
d=n1()

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

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())
d = list(map(int,input().split()))
sorted_d = sorted(d)
count = 0
for i in range(sorted_d[len(sorted_d)//2-1], sorted_d[len(sorted_d)//2]):
    count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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


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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from bisect import bisect_left 
def main():
    n = int(readline())
    d = [int(i) for i in readline().split()]
    INF = int(1e5)+1
    d.sort()
    ins_pos = n//2    
    cnt = 0 
    for k in range(1, INF):
        idx = bisect_left(d, k)
        if idx == ins_pos:
            cnt += 1
    print(cnt)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import bisect
N=int(input())
d=list(map(int,input().split()))
d=sorted(d)
num=len(d)
ans=0
val=max(d)
for i in range(val+1):
  tmp=bisect.bisect_left(d,i)
  if tmp==num-tmp:
    ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def li():
    return list(map(int, input().split()))


def mi():
    return map(int, input().split())


def ii():
    return int(input())


N = ii()
d = li()

d.sort()

mean = d[len(d) // 2]

res = 0
if d[len(d) // 2 - 1] < mean:
    res = mean - d[len(d) // 2 - 1]
print(res)

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
from bisect import bisect_left, bisect_right

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
d= LI()

d.sort()

ans = 0
for i in range(d[-1]):
    right = bisect_right(d, i)
    if right == N / 2:
        ans += 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

d = sorted(d)

a = n//2

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

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

Submission status: Accepted

Solution code:
import statistics

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

median_low = statistics.median_low(d)
median_high = statistics.median_high(d)

print(median_high-median_low)

Submission status: Accepted

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

Submission status: Accepted

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

List.sort()

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

print(int(b-a))

Submission status: Accepted

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

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

d.sort()

center = len(d)//2-1

if d[center] == d[center+1]:
    print(0)
    exit()
else:
    d[center]

    print(d[center+1]-d[center])
    exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d = 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 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

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

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = I()
d = IL()

d.sort()

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

Submission status: Accepted

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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    d = sorted(list(readnums()))
    print(d[N // 2] - d[N // 2 - 1])


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d_list = list(map(int,input().split()))
d_list.sort()
n_half = n//2
left = d_list[n_half-1]+1
right = d_list[n_half]
dum = right-left
if dum < 0:
    print(0)
else:
    print(dum+1)

Submission status: Accepted

Solution code:
N = int(input())
aList = list(map(int, input().split()))
BacketSize = [0 for n in range(100010)]
for n in range(N):
    index = aList[n]
    BacketSize[index] += 1
    
for n in range(100010):
    BacketSize[n] += BacketSize[n-1]

i = 0
count = 0
while(BacketSize[i] <= (N / 2)):
    if(BacketSize[i] == (N/2)):
        count += 1
    i += 1
print (count)

Submission status: Accepted

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

ans = 0
d.sort()

abc = d[0:n//2]
arc = d[n//2:n]
if len(abc) == len(arc):
	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)
mid_low = d[n//2-1]
mid_high = d[n//2]

print(mid_high - mid_low)

Submission status: Accepted

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

Submission status: Accepted

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