You are given a set of N numbers, where N is even. For each i from 1 to N, find the median of the set excluding Xi. The median of a set of numbers is the middle value when the numbers are ordered. The input is given in the format N followed by X1 to XN. Output N lines, where each line contains the median Bi. The constraints are 2 ≤ N ≤ 200,000, N is even, 1 ≤ Xi ≤ 10^9, and all input values are integers.

# Buggy version:
n = int(input())
x = list(map(int, input().split()))
sorted_x = sorted(x)

if sorted_x[n // 2] == sorted_x[n // 2 - 1]:
    print(' '.join([sorted_x[n // 2] * n]))
else:
    ret = []
    for i in range(n):
        if x[i] >= sorted_x[n // 2]:
            ret.append(sorted_x[n // 2])
        else:
            ret.append(sorted_x[n // 2 - 1])
    print(' '.join(ret))


# Fixed version:
n = int(input())
x = list(map(int, input().split()))
sorted_x = sorted(x)

if sorted_x[n // 2] == sorted_x[n // 2 - 1]:
    ret = [sorted_x[n // 2]] * n
else:
    ret = []
    for i in range(n):
        if x[i] >= sorted_x[n // 2]:
            ret.append(sorted_x[n // 2 - 1])
        else:
            ret.append(sorted_x[n // 2])
for i in ret:
    print(i)

# Buggy version:
def find(A):
    X=[(A[i],i) for i in range(len(A))]
    X=sorted(X)
    ans=[0]*len(X)
    p1=(len(A)-1)//2
    p2=len(A)//2
    for i in range(len(X)):
        a,b=X[i]
        if i<p2:
            ans[b]=A[p2]
        else:
            ans[b]=A[p1]
    return ans
A=[str(x) for x in find(list(map(int,input().strip().split(" "))))]
print("\n".join(A))

# Fixed version:
def find(A):
    X=[(A[i],i) for i in range(len(A))]
    X=sorted(X)
    ans=[0]*len(X)
    p1=(len(A)-1)//2
    p2=len(A)//2
    #print(p1,p2)
    for i in range(len(X)):
        a,b=X[i]
        if i<p2:
            ans[b]=X[p2][0]
        else:
            ans[b]=X[p1][0]
    return ans
input()
A=[str(x) for x in find(list(map(int,input().strip().split(" "))))]
print("\n".join(A))

# Buggy version:
from collections import Counter
N=int(input())
X=list(map(int,input().split()))
Y=sorted(X)
a=Y[N//2]
b=Y[N//2-1]
for i in range(N):
    if X[i]<=b:
        print(a)
        break
    else:
        print(b)
        break

# Fixed version:
from collections import Counter
N=int(input())
X=list(map(int,input().split()))
Y=sorted(X)
a=Y[N//2]
b=Y[N//2-1]
for i in X:
    if i<=b:
        print(a)
    else:
        print(b)

# Buggy version:
N = int(input())

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

sorted_a = sorted(a)

if N > 2:
    for i in range(int(N/2)):
        print(sorted_a[int(N/2)])
    for i in range(int(N/2)):
        print(sorted_a[int(N/2)-1])
else:
    print(a[0])


# Fixed version:
N = int(input())

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

sorted_a = sorted(a)

for i in range(N):
    if a[i] < sorted_a[int(N/2)]:
        print(sorted_a[int(N/2)])
    else:
        print(sorted_a[int(N/2)-1])

# Buggy version:
n = list(map(int,input().split()))
x = list(map(int,input().split()))
y = sorted(x)
l = y[n/2-2]
r = y[n/2-1]
for i in range(n):
    if x[I] <= l:print(r)
    else:print(l)

# Fixed version:
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
l = y[n//2-1]
r = y[n//2]
for i in range(n):
    if x[i] <= l:print(r)
    else:print(l)

# Buggy version:
from numpy import median
from copy import deepcopy

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

sx = x.sorted()
newl = deepcopy(sx)
del newl[0]
bigm = median(newl)
newl = deepcopy(sx)
del newl[-1]
minm = median(newl)

med = median(x)

for i in x:
    if i > med:
        print(minm)
    else:
        print(maxm)


# Fixed version:
from numpy import median
from copy import deepcopy

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

sx = sorted(x)
newl = deepcopy(sx)
del newl[0]
maxm = median(newl)
newl = deepcopy(sx)
del newl[-1]
minm = median(newl)

med = median(x)

for i in x:
    if i > med:
        print(int(minm))
    else:
        print(int(maxm))

# Buggy version:
N=int(input())
inp=list(map(int, input().strip().split(' ')))
Xsort=sorted(inp)
med = int(N/2)
for i in range(N):
  if Xsort[med-1] > inp[i]:
    print(Xsort[med])
  else:
    print(Xsort[med-1])

# Fixed version:
N=int(input())
inp=list(map(int, input().strip().split(' ')))
Xsort=sorted(inp)
med = int(N/2)
for i in range(N):
  if Xsort[med-1] >= inp[i] :
    print(Xsort[med])
  else:
    print(Xsort[med-1])

# Buggy version:
N = int(input())
N_d = int(N/2)
X1 = list(map(int,input().split()))
X = X1[:]
X1.sort()

def getMed(i):
  if i  < X[N_d]:
    print(X[N_d])
  else:
    print( X[N_d -1])

for i in X:
  getMed(i)
 

# Fixed version:
N = int(input())
N_d = int(N/2)
X1 = list(map(int,input().split()))
X = X1[:]
X1.sort()

def getMed(i):
  if i  < X1[N_d]:
    print(X1[N_d])
  else:
    print( X1[N_d -1])

for i in X:
  getMed(i)

# Buggy version:
import copy

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

Y = copy.deepcopy(X)
Y.sort()

largeMedian = Y[int(N / 2)]
smallMedian = Y[int(N / 2)-1]


print(X)
print(Y)
print(smallMedian)
print(largeMedian)

for i in range(N):
    if X[i] <= smallMedian:
        X[i] = largeMedian
    else:
        X[i] = smallMedian

for i in range(N):
    print(X[i], end=' ')


# Fixed version:
import copy

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

Y = copy.deepcopy(X)
Y.sort()

largeMedian = Y[int(N / 2)]
smallMedian = Y[int(N / 2)-1]

for i in range(N):
    if X[i] <= smallMedian:
        X[i] = largeMedian
    else:
        X[i] = smallMedian

for i in range(N):
    print(X[i])

# Buggy version:
n = int(input())
x = [int(a) for a in input().split()]
sorted_x = sorted(x)
print(x)
print(sorted_x)
for elem in x:
    if elem >= sorted_x[(len(x) + 1) // 2]:
        print(sorted_x[(len(x) + 1) // 2 - 1])
    else:
        print(sorted_x[(len(x) + 1) // 2])
    

# Fixed version:
n = int(input())
x = [int(a) for a in input().split()]
sorted_x = sorted(x)
for elem in x:
    if elem >= sorted_x[(len(x) + 1) // 2]:
        print(sorted_x[(len(x) + 1) // 2 - 1])
    else:
        print(sorted_x[(len(x) + 1) // 2])

# Buggy version:
n = int(input())
cn = n//2
lis = list(map(int,input().split()))
slis = sorted(lis)
if slis[cn-1] == slis[cn]:
	print(slis[cn])
else:
	for item in lis:
		if item >= slis[cn]:
			print(slis[cn-1])
		else:
			print(slis[cn])

# Fixed version:
n = int(input())
cn = n//2
lis = list(map(int,input().split()))
slis = sorted(lis)
if slis[cn-1] == slis[cn]:
	for i in range(len(lis)):
		print(slis[cn])
else:
	for item in lis:
		if item >= slis[cn]:
			print(slis[cn-1])
		else:
			print(slis[cn])

# Buggy version:
n = int(input())
a = sorted(zip(map(int, input().split()), range(n)))
for i in range(n//2):
  a[i] = a[n//2 - 1]
  a[i + n//2] = a[n//2]
print('\n'.join(map(lambda x: str(x[0]), sorted(a, key = lambda x: x[1]))))


# Fixed version:
n = int(input())
a = sorted(zip(map(int, input().split()), range(n)))
b = [0] * n
for i in range(n//2):
  b[i], b[n - i - 1] = (a[n//2][0], a[i][1]), (a[n//2 - 1][0], a[n - i - 1][1])
print('\n'.join(map(lambda x: str(x[0]), sorted(b, key = lambda x: x[1]))))

# Buggy version:
import numpy as np

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

n_list2 = list(n_list1)
n_list_test = list(n_list1)

print(n_list_test)

n_list_max = np.max(n_list1)
n_list_min = np.min(n_list2)

n_list1.remove(n_list_max)
n_list2.remove(n_list_min)

# print(np.max(n_list))
# np.median(n_list - )
n_list1_median = int(np.median(n_list1))
n_list2_median = int(np.median(n_list2))

print(n_list1_median)
print(n_list2_median)

for x in n_list_test:
  if n_list1_median >= x:
    print(n_list2_median)
  else:
    print(n_list1_median)
 
    



# Fixed version:
import numpy as np

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

n_list2 = list(n_list1)
n_list_test = list(n_list1)


n_list_max = np.max(n_list1)
n_list_min = np.min(n_list2)

n_list1.remove(n_list_max)
n_list2.remove(n_list_min)

# print(np.max(n_list))
# np.median(n_list - )
n_list1_median = int(np.median(n_list1))
n_list2_median = int(np.median(n_list2))

for x in n_list_test:
  if n_list1_median >= x:
    print(n_list2_median)
  else:
    print(n_list1_median)

# Buggy version:
n = int(input())
l0 = list(map(int, input().split()))
l = sorted(l0)

m1 = l[n//2 - 1]
m2 = l[n//2]
for i in range(len(l0)):
    if l0[i] <= m2:
        print(m2)
    if l0[i] > m1:
        print(m1)


# Fixed version:
n = int(input())
l0 = list(map(int, input().split()))
l = sorted(l0)

m1 = l[n//2 - 1]
m2 = l[n//2]
for i in range(len(l0)):
    if l0[i] < m2:
        print(m2)
    elif l0[i] > m1:
        print(m1)
    elif l0[i] == m1:
        print(m2)
    elif l0[i] == m2:
        print(m1)

# Buggy version:
N = int(input())
x = sorted(list(map(int, input().split())))
for i in range(N):
    if i <= N // 2 - 1:
        print(x[N//2])
    else:
        print(x[N//2-1])


# Fixed version:
N = int(input(
))
X = list(map(int,input().split()))

X_sorted = sorted(X)

for i in range(N):
    x = X[i]
    if x < X_sorted[N//2]:
        print(X_sorted[N//2])
    else:
        print(X_sorted[N//2-1])