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()))
D.sort()

tmp = D[N // 2] - D[N // 2 - 1]

print (tmp)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N, *A = map(int, open(0).read().split())
A.sort()

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

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]
print(R - L)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

m = n//2

x,y = d[m-1:m+1]
ans = y - x
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

d = sorted(d)
print( max( 0, d[ N // 2 ] - d[ N // 2 - 1 ] ) )

Submission status: Accepted

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

Submission status: Accepted

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

ds = sorted(d)

sub = ds[n//2] - ds[n//2-1]

print(sub)

Submission status: Accepted

Solution code:
import math

n=int(input())
li = list(map(int,input().split()))
li.sort()
print(li[math.floor(n/2)]-li[math.floor(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=[int(i) for i in input().split(" ")]
d.sort()
print(d[int(N/2)]-d[int(N/2-1)])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import statistics
import math
n = int(input()) 
s = list(map(int,input().split()))
s.sort()

med_ind = len(s)//2 -1
#print(med_ind)
ans = s[med_ind+1]-s[med_ind]
#print(s[med_ind+1],s[med_ind])
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())//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()))
d.sort()
if d[n//2]==d[n//2-1]:
    print(0)
else:
    print(d[n//2]-d[n//2-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
D = list(map(int, input().split()))
D.sort()
A = D[: n // 2]
B = D[n // 2:]
print(B[0] - 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())
ds = map(int, input().split())
ds = sorted(ds)
midind = N // 2 

print(ds[midind] - ds[midind-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

    d.sort()

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

solve()

Submission status: Accepted

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

d_n = sorted(d_n, reverse=False)
med = int(n / 2)

count = 0
for i in range(d_n[med - 1], d_n[med], 1):
    count = count + 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

a = l[:int(n/2)]
b = l[int(n/2):]

x = b[0] - a[len(a)-1]

print(x)

Submission status: Accepted

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

Submission status: Accepted

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

n,*L=map(int,read().split())
L.sort()
num=abs(L[n//2-1]-L[n//2])
print(num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Ds.sort()

D1, D2 = Ds[N//2-1], Ds[N//2]

print(D2-D1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys
n = int(input())
li = list(map(int, input().split()))
li.sort()
if (len(li) % 2 == 0):
    print(li[len(li)//2] - li[len(li)//2 - 1])
else:
    print(0)

Submission status: Accepted

Solution code:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())

n = int(input())
d = sorted(list(map(int, input().split())))
x = n//2
print(d[x] - d[x-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:
import bisect
N = int(input())
d = list(map(int, input().split()))
d = sorted(d)
mn = min(d)
mx = max(d)
ans = 0
for i in range(mn, mx+1):
  idx = bisect.bisect_left(d, i)
  if idx == N//2:
    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if T[N//2]==T[(N-2)//2]:
  print("0")
else:
  print(T[N//2]-T[(N-2)//2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import sys
n = int(input())
li = list(map(int, input().split()))
li.sort()
ans=0
if (len(li) % 2 == 0):
    ans = li[len(li)//2] - li[len(li)//2 - 1]
print(ans)

Submission status: Accepted

Solution code:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
d = inputlist()
d.sort()
i1 = N//2
i0 = i1-1
print(d[i1]-d[i0])

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


div = int(n / 2)


if len(d) % 2 == 0:
    print(d[div] - d[div-1])
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:
# C - Divide the Problems

n = int(input())
d = list(int(x) for x in input().split())
d.sort()

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

m=n//2

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

Submission status: Accepted

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

m=n//2

if a[m] == a[m-1] :print(0);exit()

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

Submission status: Accepted

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

Submission status: Accepted

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

l=a[N//2 -1]
r=a[N//2]

print(r-l)

Submission status: Accepted

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

problemList = sorted(problemList)
mid = N // 2

ans = problemList[mid] - problemList[mid-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()
S = sum(d)
print(d[N//2]-d[N//2 - 1])

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int,input().split()))
Semi = 0
i = 0
D.sort()
while i != N//2:
    Semi = D[i]
    i += 1
if len([el for el in D if el > Semi]) != N//2:
    print(0)
else:
    print(min([el for el in D if el > Semi])-Semi)

Submission status: Accepted

Solution code:
def elip():
    return map(int,input().split())
N = int(input())
D = list(elip())
Semi = 0
i = 0
D.sort()
while i != N//2:
    Semi = D[i]
    i += 1
if len([el for el in D if el > Semi]) != N//2:
    print(0)
else:
    print(min([el for el in D if el > Semi])-Semi)

Submission status: Accepted

Solution code:
n = int(input())

d_list = [int(x) for x in input().split()]
d_list.sort()

n >>= 1
ans = d_list[n] - d_list[n - 1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
import sys
input = sys.stdin.readline

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

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

Submission status: Accepted

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

d.sort()
l = len(d)

mi = d[l//2 - 1] + 1
ma = d[l//2]

ans = ma - mi + 1
if ans >= 0:
    print(ans)
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

sd = sorted(d)
law = sd[N//2 -1]
high = sd[N//2]

print(high - law)

Submission status: Accepted

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

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

Submission status: Accepted

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

d = sorted(d)
l = len(d)

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

else:
    print(0)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 22 00:34:54 2020

@author: Kanaru Sato
"""

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

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

Submission status: Accepted

Solution code:
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n = II()
    D = LI()

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

from collections import deque

def solve():
    n = II()
    D = deque(sorted(LI()))

    for i in range(n):
        l = D.popleft()
        # print('l', l)
        if len(D) == 0:
            print(1)
            break
        else:
            r = D.pop()
            # print('r', r)
            if len(D) == 0:
                print(r - l)
                break
            else:
                continue




if __name__ == '__main__':
    solve()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


N = int(input())
D = list(map(int, input().split()))
D = sorted(D)
#
# counter = 0
# for i in range(D[N // 2], D[N // 2 - 1], -1):
#     counter += 1

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N, A, B = map(int, input().split())
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
N = int(input())
D = list(map(int, input().split()))
D = sorted(D)

counter = 0
for i in range(D[N // 2], D[N // 2 - 1], -1):
    counter += 1

print(counter)



# def main():

# if __name__ == '__main__':
#     main()

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:
def main():
    N = int(input())
    D = [int(a) for a in input().split()]
    D.sort()
    l = D[N//2-1]
    r = D[N//2]
    print(r-l)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
d = list(map(int, input().split()))

d.sort()
h = n // 2 - 1

a = d[h]
b = d[h + 1]

print(b - a)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    b = list(set(s))
    a = len(list(set(s)))
    if a == 2 and s.count(b[0]) == s.count(b[1]) == 2:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
            ans += 1
    print(ans)
    return

#C
def C():
    n = II()
    d = LI()
    d.sort()
    ans = 0
    for i in range(10**5+1):
        if n // 2 == bisect_left(d, i):
            ans += 1
    print(ans)
    return


def combination_mod(n, k, mod):
    # power_funcを用いて(nCk) mod p を求める 
    # nCk = n!/((n-k)!k!)を使用

    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = factorial(n) % mod
    b = factorial(k) % mod
    c = factorial(n - k) % mod
    return (a * power_func(b, mod - 2, mod) * power_func(c, mod - 2, mod)) % mod
    
def power_func(a, b, mod):
    # a^b mod p を求める
    # bを2進数分解して高速累乗

    if b == 0: return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, mod)
        return d * d % mod
    if b % 2 == 1:
        return (a * power_func(a, b - 1, mod)) % mod

#D
def D():
    n, k = LI()
    ans = 0
    for i in range(1,k+1):
        a = combination_mod(n - k + 1, i, mod)
        b = combination_mod(k - 1, i - 1, mod)
        print((a*b)%mod)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
d = LIST()

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = l[a]-l[a-1]

print(ans)

Submission status: Accepted

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

ans = d[num]-d[num-1]

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

nums.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()

h1 = d[n//2]
h2 = d[n//2 - 1]

ans = [i for i in range(h2,h1)]

print(len(ans))

Submission status: Accepted

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

ld = sorted(ld)

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)

def main():
    N = int(input())
    D = list(map(int, sys.stdin.readline().rstrip().split()))
    D.sort()
    print(max(0, 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.sort()
if d[n//2-1]==d[n//2]:
  print(0)
else:
  print(d[n//2]-d[n//2-1])

Submission status: Accepted

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

left = d[N // 2 - 1]
right = d[N // 2]
ans = right - left

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# solution
import io
import fractions

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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:
import sys

n, *a = map(int, sys.stdin.read().split())
a.sort()

def main():
    m = n // 2
    l, r = a[m-1], a[m]
    print(r - l)
    
if __name__ ==  '__main__':
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
import statistics
d.sort()
a = statistics.median_low(d)
c = statistics.median_high(d)

if a == c:
    print(0)
else:
    print((c-a))

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    D = sorted(readInts())
    dl = len(D)//2
    print(D[dl] - D[dl-1])
if __name__ == '__main__':
  main()

Submission status: Accepted

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

same = N / 2

# d.sort()

# distribution = [0] * d[len(d) - 1]
# total = 0
# for di in d:
#     num = d.count(di)
#     distribution[di - 1] = num

table = {}
for di in d:
    table[di] = 1 if table.get(di) is None else table.get(di) + 1
table = sorted(table.items())

total = 0
start = 0
end = 0
for difficulty, num in table:
    total += num

    if start == 0 and total == same:
        start = difficulty
    elif start != 0:
        end = difficulty
        break

# print(table, start, end)

answer = end - start
print(answer)

Submission status: Accepted

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

abc = d_inputs[0:n//2]
arc = d_inputs[n//2:n]

print(len([i for i in range(abc[-1]+1,arc[0]+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:
# coding: utf-8
# Your code here!

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

n,*d=map(int,open(0).read().split())

d.sort()

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

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

Submission status: Accepted

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

if n%2 ==0:
  n = int(n/2)
else:
  exit()
  
sortedList = sorted(d)

ans = sortedList[n] - sortedList[n-1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

d_beg, d_reg = d[N // 2 - 1], d[N // 2]
print(len(list(range(d_beg, d_reg))))

Submission status: Accepted

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