CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
p = sorted(list(map(int, input().split())))
mid = n // 2
ans = 0
for i in range(p[mid-1], p[mid]):
  if len([j for j in p if j > i]) == mid:
    ans += 1
print(ans)

# Optimized solution
n = int(eval(input()))
p = sorted(list(map(int, input().split())))
mid = n // 2
print((p[mid] - p[mid-1]))
# Original solution
N=int(eval(input()))
D=list(map(int,input().split()))
D.sort()
mi=D[0]
ma=D[N-1]
point=0
for j in range(mi,ma+1): #Kはj
    i=0
    while D[i]<j and i<N-1:
        i+=1
    if i==N//2 :
        point+=1
print(point)

# Optimized solution
N=int(eval(input()))
D=list(map(int,input().split()))
D.sort()
mi=D[0]
ma=D[N-1]
point=0
for j in range(mi,ma+1): #Kはj
    if D[N//2-1]<j<=D[N//2]:
        point+=1
print(point)
# Original solution
n = int(eval(input()))
dif = [int(i) for i in input().split()]

max_dif = max(dif)

ans = 0
for i in range(max_dif+1):
	ARC = []
	ABC = []
	for j in range(n):
		if dif[j] >= i:
			ARC.append(dif[j])
		else:
			ABC.append(dif[j])
			
	if len(ARC) == len(ABC):
		ans += 1
		
print(ans)

# Optimized solution
n = int(eval(input()))
dif = [int(i) for i in input().split()]

dif.sort()

print((dif[n//2] - dif[n//2 -1]))
# Original solution
import statistics

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

L=0
R=0
DDT = 0
ans = 0
for K in range(statistics.median_low(d)-min(d),statistics.median_low(d)+max(d)):
    for i in range(N):
        if d[i] == K:
            DDT += 1
        elif d[i] < K:
            L += 1
        else:
            R += 1
    if L == R:
        ans += 1
    else:
        while DDT > 0:
            if L < R:
                L += 1
                DDT -= 1
            elif L > R:
                R += 1
                DDT -= 1
            else:
                L += 1
                DDT -= 1
        if L == R:
            ans += 1
    L = 0
    R = 0
    DDT = 0
print((ans-1))

# Optimized solution
N = int(eval(input()))
d = input().split()
d = list(map(int,d))

d.sort()

ans = d[N//2] - d[(N//2)-1]
print(ans)
# Original solution
n,*l=list(map(int,open(0).read().split()));n//=2;l.sort();print((l[n]-l[~n]))

# Optimized solution
n,*d=list(map(int,open(0).read().split()))
l,r=sorted(d)[n//2-1:n//2+1]
print((r-l))
# Original solution
n,*l=list(map(int,open(0).read().split()))
n//=2
l.sort()
print((l[n]-l[~n]))

# Optimized solution
m=int(eval(input()))//2
l=sorted(map(int,input().split()))
print((l[m]-l[~m]))
# Original solution
n = int(eval(input()))
p = list(map(int, input().split()))
ans = 0
for k in range(1, max(p) + 1):
    abc = 0
    arc = 0
    for i in p:
        if i < k:
            abc += 1
        else:
            arc += 1
    if abc == arc:
        ans += 1
print(ans)


# Optimized solution
n = int(eval(input()))
p = sorted(list(map(int, input().split())))
a = int(len(p) / 2)
if p[a-1] == p[a]:
    print((0))
else:
    print((p[a] - p[a-1]))
# Original solution
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(eval(input()))
    return x

neko = 0
nya = 0
nuko = 0

n = iin()
d = [int(x) for x in input().split()]
d.sort()

neko = int(n/2 - 1)
nuko = neko + 1
if d[neko] != d[nuko]:
    for i in range(d[nuko]-d[neko]):
        nya = nya + 1
    
print(nya)

# Optimized solution
n = int(eval(input()))
d = list(map(int,input().split()))
d = sorted(d)
ans = d[n//2] - d[n//2-1]
print(ans)
# Original solution
#!/usr/bin/env python3
#ABC132 C

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

ans = 0
for i in range(min(d),max(d)):
    s = 0
    t = 0
    for j in range(N):
        if d[j] <= i:
            s += 1
        else:
            t += 1
        if s > N//2:
            break
        if t > N//2:
            break
    if s == t:
        ans += 1
print(ans)


# Optimized solution
#!/usr/bin/env python3
#ABC132 C
import sys
sys.setrecursionlimit(1000000)
from collections import deque

N = int(eval(input()))
d = list(map(int,input().split()))
d.sort()
if N % 2 == 0:
    print((d[N//2]-d[N//2-1]))
else:
    print((0))
# Original solution
n = int(eval(input()))
q = list([int(x) for x in input().split()])
a = max(q)
b = min(q)
cnt = 0
for d in range(b,a+1):
    ARC = 0
    ABC = 0
    for qq in q:
        if qq >= d : ARC += 1
        else: ABC += 1
    if ARC == ABC:
        cnt += 1
print(cnt)

# Optimized solution
n = int(eval(input()))
q = list([int(x) for x in input().split()])
q.sort()
cnt = q[int(n/2)] - q[int(n/2)-1]
print(cnt)
# Original solution
n=int(eval(input()))
li = list(map(int,input().split()))

li.sort()

ind=int(n//2)-1

count=0
for k in range(li[ind]+1,li[ind+1]+1):
  miman=0
  ijou=0
  for num in li:
    if num >= k:
      ijou+=1
    elif num < k:
      miman+=1
      
  if ijou==miman:
    count+=1
    
print(count)

# Optimized solution
n=int(eval(input()))
li = list(map(int,input().split()))

li.sort()

ind=int(n//2)-1

count=0

for k in range(li[ind]+1,li[ind+1]+1):
  count+=1
  
print(count)
# Original solution
n=int(eval(input()))
li = list(map(int,input().split()))

li.sort()

ind=int(n//2)-1

count=0

for k in range(li[ind]+1,li[ind+1]+1):
  count+=1
  
print(count)

# Optimized solution
n=int(eval(input()))
#a,b=map(int,input().split())
dl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
ans=1
dl.sort()
if n%2==0:
    mid=n//2
    ans=dl[mid]-dl[mid-1]
print(ans)
# Original solution
N=int(eval(input()))

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

a=sorted(m)
count=0

for i in range(min(a),max(a)+1):
    b=[j for j in a if i > j]
    if len(b) == N/2:
        count +=1
          
print(count)           

# Optimized solution
N=int(eval(input()))

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

a=sorted(m)

ans=a[int(N/2)]-a[int(N/2)-1]
    
          
print(ans)
# Original solution
n = int(eval(input()))
d = list(map(int, input().split()))
d.sort()
half = len(d) // 2
print((d[half] - d[half - 1]))

# Optimized solution
n = int(eval(input()))
d = list(map(int, input().split()))
d.sort()
half = n // 2
print((d[half] - d[half - 1]))
# Original solution
def main():
    n = int(eval(input()))
    d = list(map(int, input().split()))
    d.sort()
    half = n // 2
    print((d[half] - d[half - 1]))


if __name__ == "__main__":
    main()

# Optimized solution
import sys


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


if __name__ == "__main__":
    main()
# Original solution
N = int(eval(input()))
D = [int(i) for i in input().split()]

cnt = 0
for i in range(max(D)+1):
  ARC = 0
  ABC = 0
  for d in D:
    if i <= d:
      ARC +=1
    else:
      ABC +=1
  if ARC == ABC:
    cnt +=1
print(cnt)

# Optimized solution
N = int(eval(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)
# Original solution
n=int(eval(input()))
L=list(map(int,input().split()))
L.sort()

m=int(n/2)
cnt=0
for i in range(L[m-1]+1,L[m]+1):
    
    if len(L[:m])==m:
        cnt+=1
        
print(cnt)

# Optimized solution
n=int(eval(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]))
# Original solution
n=int(eval(input()))
d=list(map(int,input().split()))
cnt=0
for i in range(min(d),max(d)+1):
    abc=0
    arc=0
    for j in range(len(d)):
        if d[j] <= i:
            abc+=1
        else:
            arc+=1
    if abc == arc:
        cnt+=1
print(cnt)

# Optimized solution
n=int(eval(input()))
d=list(map(int,input().split()))
A=sorted(d)
print((A[len(d)//2]-A[(len(d)//2)-1]))
# Original solution
n=int(eval(input()))
d=list(map(int,input().split()))
A=sorted(d)
print((A[len(d)//2]-A[(len(d)//2)-1]))


# Optimized solution
n=int(eval(input()))
d=list(map(int,input().split()))
d=sorted(d)
print((d[len(d)//2]-d[len(d)//2-1]))
# Original solution
N = int(eval(input()))
d = [int(x) for x in input().split()]

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

print((b - a))

# Optimized solution
N = int(eval(input()))
d = list(map(int, input().split()))
d.sort()

left = d[N // 2 - 1]
right = d[N // 2]
print((right - left))
# Original solution
N = int(eval(input()))
d = list(map(int, input().split()))
d.sort()

left = d[N // 2 - 1]
right = d[N // 2]
print((right - left))

# Optimized solution
N = int(eval(input()))
d = list(map(int, input().split()))
d.sort()
n = N // 2 -1
print((d[n+1] - d[n]))
# Original solution
N = int(eval(input()))
d = list(map(int, input().split()))
d.sort()
n = N // 2 -1
print((d[n+1] - d[n]))

# Optimized solution
n = int(eval(input()))
d = sorted(list(map(int, input().split())))
l,r = d[n//2-1], d[n//2]
print((r-l))
# Original solution
n = int(eval(input()))
d = list(map(int, input().split()))
if(len(d)%2 == 0):
    d.sort()
    t = int(len(d)/2)-1
    s = d[t]
    m = s
    i = t
    while (d[t+1] > s):
        s += 1
    print((s-m))
else:
    print((0))

# Optimized solution
n = int(eval(input()))
d = list(map(int, input().split()))
if(len(d)%2 == 0):
    d.sort()
    t = int(len(d)/2)-1
    print((d[t+1] - d[t]))
else:
    print((0))
# Original solution
N=int(eval(input()))
d=list(map(int, input().split()))

d=sorted(d)
ans=0
 
for i in range(10**7):
    if d[int(N/2-1)] < i and i <= d[int(N/2)]:
        ans +=1
 
print(ans)

# Optimized solution
N=int(eval(input()))
d=list(map(int, input().split()))
 
d=sorted(d)
ans=0
 
for i in range(10**6):
    if d[int(N/2-1)] < i and i <= d[int(N/2)]:
        ans +=1
 
print(ans)
# Original solution
N=int(eval(input()))
d=list(map(int, input().split()))
 
d=sorted(d)
ans=0
 
for i in range(10**6):
    if d[int(N/2-1)] < i and i <= d[int(N/2)]:
        ans +=1
 
print(ans)

# Optimized solution
N=int(eval(input()))
d=list(map(int, input().split()))
 
d=sorted(d)
ans=0
 
for i in range(1+10**5):
    if d[int(N/2-1)] < i and i <= d[int(N/2)]:
        ans +=1
 
print(ans)
# Original solution
N=int(eval(input()))
suu=(N/2)-1
d=list(map(int,input().split()))
for n in range(round(suu)):
    s=d.index(max(d))
    d.pop(s)
dai=max(d)
s=d.index(max(d))
d.pop(s)
syo=max(d)
print((dai-syo))


# Optimized solution
N=int(eval(input()))
d=list(map(int,input().split()))
d.sort()
dai=d[round((N/2)-1)]
syo=d[round(N/2)]
print((syo-dai))
# Original solution
N  = int(eval(input()))
nums = list(map(int,input().split()))
nums.sort()
cnt = 0
for i in range(min(nums),max(nums)+1):
  if len(list(j for j in nums if j >= i)) == N //2 :
    cnt += 1
print(cnt)

# Optimized solution
N  = int(eval(input()))
nums = list(map(int,input().split()))
nums.sort()
cnt = nums[N//2] - nums[N//2-1] 
print(cnt)
# Original solution
import sys

n, *d = list(map(int, sys.stdin.read().split()))

def main():
    d.sort()
    h = n // 2
    l = d[h-1]; r = d[h]
    return r - (l + 1) + 1

if __name__ == '__main__':
    ans = main()
    print(ans)

# Optimized solution
import sys

n, *a = list(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()
# Original solution
# Check Examples

#python 3.7.
# Check Examples

#python 3.7.1

n=int(eval(input()))
p=input().split()  
p=list(map(int,p))          
cnt=0
det=len([])

p=sorted(p)
for i in range(n):
	arc=p[i:]
	abc=p[:i]
	
	if det and len(arc)<=len(abc):
		cnt=p[i]-p[i-1]
		break
	if arc>abc:det=True

print (cnt)



# Optimized solution
# Check Examples

#python 3.7.1

n=int(eval(input()))
p=input().split()  
p=list(map(int,p))          
cnt=0

p=sorted(p)

if p[n//2]!=p[(n//2)-1]:
	cnt=p[n//2]-p[(n//2)-1]



print (cnt)
# Original solution
n = int(eval(input()))
d = list(map(int,input().split()))
k = max(d)
i = 0
j = 0
ans = 0
b = 0
s = 0
while i <= k:
  while j <= n-1:
    if d[j] < i:
      s += 1
    if d[j] >= i:
      b += 1
    j += 1
  if b == s:
    ans += 1
  b = 0
  s = 0
  j = 0
  i += 1
print(ans)
  

# Optimized solution
n = int(eval(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)
# Original solution
import sys

n=int(eval(input()))
ls=list(map(int,input().split()))
ls.sort()
end_k=ls[len(ls)//2]

cnt=0

for i in range(end_k):
    num=0
    for j in range(n):
        if ls[j]>i:
            num+=1
    if num==n//2:
        cnt+=1

print(cnt)


# Optimized solution
n=int(eval(input()))
ls=list(map(int,input().split()))
ls.sort()

print((ls[n//2]-ls[n//2-1]))
# Original solution
N = int(eval(input()))
d = list(map(int, input().split()))
d.sort()

s, t = N//2-1, N//2

cnt = 0
for i in range(d[s],d[t]+1):
    tmp = [x>=i for x in d]
    if tmp.count(True)==tmp.count(False):
        cnt += 1
print(cnt)

# Optimized solution
N = int(eval(input()))
d = list(map(int, input().split()))
d.sort()

s, t = N//2-1, N//2

ans = d[t] - d[s]
print(ans)
# Original solution
n=int(eval(input()))
p=list(map(int, input().split()))
c=0
x = sorted(p)
a,b= x[int(n/2)-1], x[int(n/2)]
for k in range(a, b+1):
  arc = []
  abc = []
  for i in p:
    if k >= i:
      arc.append(arc)
    elif k <= i:
      abc.append(abc)
  if len(arc) == len(abc):
    c+=1
print(c)

# Optimized solution
n=int(eval(input()))
p=sorted(list(map(int, input().split())))
print((p[int(n/2)]-p[int(n/2)-1]))
# Original solution
n = int(eval(input()))
d = list(map(int, input().split()))
ans = 0
for i in range(max(d)):
	a = sum(x > i for x in d)
	if a == (n/2):
		ans += 1
print(ans)


# Optimized solution
n = int(eval(input()))
d = list(map(int, input().split()))
d.sort()
print((d[n//2]-d[(n//2)-1]))
# Original solution
from collections import Counter
N = int(eval(input()))
D = list(map(int, input().split()))

cnt = Counter(D)
lst = []
for key in sorted(cnt.keys()):
    lst.append([key, cnt[key]])

ans = 0
tmp = 0
for i, kv in enumerate(lst):
    key, value = kv
    tmp += value
    if tmp == N - tmp:
        if i + 1 < len(lst):
            ans = lst[i+1][0] - key
            break
        else:
            break
print(ans)

# Optimized solution
n = int(eval(input()))
d = sorted(map(int, input().split()))

a = d[n//2-1]
b = d[n//2]
print((b-a))
# print(d)
# Original solution
n=int(eval(input()))
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[n-1]
sum1=0
sum2=0
count=0
for k in range(N+1):
    for i in range(n):
        if d[i]>=k:
            sum1+=1
    if sum1==n-sum1:
        count+=1
    sum1=0
    sum2=0
print(count)

# Optimized solution
n=int(eval(input()))
d=list(map(int,input().split()))
dd=sorted(d)
N=dd[int((n/2))]-dd[int((n/2)-1)]
print(N)
# Original solution
#!/usr/bin/ python3.8
N=int(eval(input()))
d=[int(x) for x in input().split()]
d=sorted(d)

if N%2==1:
    print((0))
    exit(0)

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


# Optimized solution
#!/usr/bin/ python3.8
N=int(eval(input()))
d=[int(x) for x in input().split()]
d.sort()
if N%2==1:
    print((0))
    exit(0)
x,y=d[N//2-1:N//2+1]
print((y-x))
# Original solution
N = int(eval(input()))
D = list(map(int, input().split()))
D.sort()
ans = 0
for i in range(D[N // 2 - 1], max(D)) :
  cnt = len(list([x for x in D if x <= i]))
  if(cnt == N // 2) :
    ans += 1
  elif(cnt > N // 2) :
    break
  else :
    pass
print(ans)

# Optimized solution
N = int(eval(input()))
D = list(map(int, input().split()))
D.sort()
ans = 0
for i in range(N // 2) :
  cnt = len(list([x for x in D if x <= D[N // 2 - 1 + i]]))
  if(cnt == N // 2) :
    ans += D[N // 2] - D[N // 2 - 1]
  elif(cnt > N // 2) :
    break
  else :
    pass
print(ans)
# Original solution
N = int(eval(input()))
d = list(map(int, input().split()))
d.sort()
print((d[N//2]-d[N//2-1]))

# Optimized solution
import sys
input = sys.stdin.readline

N = int(eval(input()))
d = list(map(int, input().split()))
d.sort()
print((d[N//2]-d[N//2-1]))
# Original solution
N = int(eval(input()))
D = list(map(int, input().split()))

def quicksort(a):
  if len(set(a)) < 2:
    return a
  left = []
  center = a.pop(0)
  right = []
  for i in a:
    if center > i:
      left.append(i)
    else:
      right.append(i)
  left = quicksort(left)
  right = quicksort(right)
  left.append(center)
  left.extend(right)
  return left

D = quicksort(D)

left = D[int((N/2)-1)]
right = D[int(N/2)]
ans = 0
if left < right:
  ans = right - left
print(ans)



# Optimized solution
N = int(eval(input()))
d = list(map(int, input().split()))
d.sort()
middle = (N // 2) -1
print((d[middle+1] - d[middle]))
# Original solution
N=int(eval(input()))
d=list(map(int, input().split()))
d.sort()
left=d[N//2 -1]
right=d[N//2]
cnt=0
for i in range(left+1, right+1): #left+1<= i <=right
    cnt+=1

print(cnt)


# Optimized solution
N=int(eval(input()))
d=list(map(int, input().split()))
a=sorted(d)

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

print((r-l))
# Original solution
n=int(eval(input()))
d=[int(x) for x in input().rstrip().split()]
d.sort()
if d[n//2-1]==d[n//2]:
  print((0))
else:
  print((d[n//2]-d[n//2-1]))


# Optimized solution
n=int(eval(input()))
d=[int(x) for x in input().rstrip().split()]
d.sort()
ind=n//2

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

else:
  print((d[ind]-d[ind-1]))
# Original solution
n = int(eval(input()))
d = [int(i) for i in input().split()]
d.sort()
k = d[n // 2] - d[(n // 2) - 1]
print(k)

# Optimized solution
n = int(eval(input()))
d = sorted([int(i) for i in input().split()])
print((d[n//2] - d[n//2 - 1]))
# Original solution
n = int(eval(input()))
d = sorted([int(i) for i in input().split()])
print((d[n//2] - d[n//2 - 1]))

# Optimized solution
n = int(eval(input()))
d = sorted(list(map(int, input().split())))
print((d[n//2] - d[n//2 - 1]))
# Original solution
n = int(eval(input()))
p = list(map(int, input().split(" ")))
a = 0
for r in range(min(p) - 1, max(p)+1):
    abc = list([x for x in p if x < r])
    arc = list([x for x in p if x >= r])
    if len(abc) == len(arc) :
        a += 1
print(a)

# Optimized solution
n = int(eval(input()))
p = list(map(int, input().split(" ")))
a = 0
p.sort()
n_2 = int(n / 2)
abc = p[:n_2]
arc = p[n_2:]
a = arc[0] - (abc[len(abc) - 1]) 
print(a)
# Original solution
n = int(eval(input()))
l = list(map(int, input().split()))
for i in range(int(n/2-1)):
  l.remove(max(l))
  l.remove(min(l))
r = abs(l[1]-l[0])
print(r)

# Optimized solution
n = int(eval(input()))
l = sorted(list(map(int, input().split())))
d = int(n / 2)
r = l[d] - l[d-1]
print(r)
# Original solution
from collections import Counter

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

minD = min(d)
maxD = max(d)
c = Counter(d)

abc = 0
arc = n
ans = 0

for i in range(minD, maxD+1):
    abc += c[i-1]
    arc -= c[i-1]
    
    if abc == arc:
        ans += 1

print(ans)

# Optimized solution
n = int(eval(input()))
d = list(map(int, input().split()))

d.sort()

print((max(0, d[n//2] - d[n//2 - 1])))
# Original solution
N = int(eval(input()))
d = list(map(int,input().split()))

max_k = max(d)
min_k = min(d)

d.sort()

abc = []
arc = []
count = 0

for k in range(min_k,max_k + 1):
    abc = [num for num in range(0,N) if d[num] < k]
    arc = [num for num in range(0,N) if d[num] >= k]
    if(len(abc) == len(arc)):
        count += 1
print(count)



# Optimized solution
N = int(eval(input()))
d = list(map(int,input().split()))
max_k = max(d)
min_k = min(d)
d.sort()
half = N // 2
print((d[half] - d[half - 1]))
# Original solution
N = int(eval(input()))
d = list(map(int,input().split()))
max_k = max(d)
min_k = min(d)
d.sort()
half = N // 2
print((d[half] - d[half - 1]))

# Optimized solution
N = int(eval(input()))
d = list(map(int,input().split()))
d.sort()
half = N // 2
print((d[half] - d[half - 1]))
# Original solution
N = int(eval(input()))
p = list(map(int,input().split()))

ans = 0
for j in range(max(p)):
    agc = [i for i in p if i>j]
    if len(agc) == len(p)-len(agc):
        ans += 1

print(ans)

# Optimized solution
N = int(eval(input()))
p = list(map(int,input().split()))
p = sorted(p)
c = p[N//2-1]
d = p[N//2]
print((d-c))
# Original solution
N=int(eval(input()))
d=list(map(int, input().strip().split()))
ans=0

d.sort()

for i in range(int(d[int(N/2)-1]),int(d[int(N/2)]+1)):
    ABC=0
    ARC=0
    for j in range(int(N)):

        if d[j]<i:
            ABC+=1
        else:
            ARC+=1

    if ARC==ABC:
        ans+=1

print(ans)


# Optimized solution
N=int(eval(input()))
d=list(map(int, input().strip().split()))
ans=0

d.sort()

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

print((int(d[int(N/2)])-int(d[int(N/2)-1])))
# Original solution
#!/usr/bin/env python3
import sys


def solve(N: int, d: "List[int]"):
    import bisect
    d.sort()
    if(N%2 == 1):
        print((0))
    else:
        print((d[int(N/2)] - d[int(N/2)-1]))
    return


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

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, d: "List[int]"):
    d.sort()
    s = d[N//2-1]
    e = d[N//2]
    print((e-s))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()
# Original solution
import sys
import collections as c

input = sys.stdin.readline

def main():
    ans = 0
    n = int(eval(input()))
    d = list(map(int, input().split()))
    d.sort()
    g = d[n//2]
    items_count = c.Counter(d)
    gc = items_count[g]
    if gc == 1 or d[n//2-1] != g:
        ans += g - d[n//2-1]
    print(ans)

if __name__ == '__main__':
    main()

# Optimized solution
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(eval(input()))
    d = list(map(int, input().split()))
    d.sort()
    ans += d[n//2] - d[n//2-1]
    print(ans)

if __name__ == '__main__':
    main()
# Original solution
s = int(eval(input()))
list = [int(n) for n in input().split()]

print((sorted(list)[s//2] - sorted(list)[s//2 - 1]))


# Optimized solution
s = int(eval(input()))
list = [int(n) for n in input().split()]

s_l = sorted(list)
print((s_l[s//2] - s_l[s//2 - 1]))
# Original solution
N = int(eval(input()))
d = list(map(int,input().split()))

count = 0
for K in range(min(d),max(d)+1):
    ARC = [i for i in d if i >= K]
    ABC = [j for j in d if j < K]
    if len(ARC) == len(ABC):
        count += 1
print(count)

# Optimized solution
N = int(eval(input()))
d = list(map(int,input().split()))
d_sorted = sorted(d, reverse = False)

count = d_sorted[(N-1) //2 + 1] - d_sorted[(N-1) // 2]
print(count)
# Original solution
N = int(eval(input()))
d_list = list(map(int, input().split()))

d_list.sort()
from bisect import bisect_right
ans = 0

for i in range(1, max(d_list)):
    idx = bisect_right(d_list, i)
    if N //2 == idx:
        ans += 1
print(ans)


# Optimized solution
N = int(eval(input()))
d_list = list(map(int, input().split()))

d_list.sort()

print((d_list[N//2] - d_list[N//2 - 1]))
# Original solution
n = int(eval(input()))
d = list(map(int, input().split()))
min = min(d)
max = max(d)
count = 0
for k in range(min,max+1) :
    abc = 0 ; arc = 0
    for idx in range(n) :
        if d[idx] >= k :
            arc += 1
        else :
            abc += 1
    if abc == arc :
        count += 1
print(count)


# Optimized solution
n = int(eval(input()))
d = sorted(map(int, input().split()))
med_idx = int(n/2)
print((d[med_idx]-d[med_idx-1]))
# Original solution
n = int(eval(input()))
d = list(map(int, input().split()))
d_max = max(d)
d_half = len(d) // 2
ans = 0

for i in range(1, d_max+1):
    abc = [x for x in d if x < i]
    if len(abc) == d_half:
        ans += 1

print(ans)

# Optimized solution
n = int(eval(input()))
d = list(map(int, input().split()))
d.sort()

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