When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.
You are given N numbers X_1, X_2, ..., X_N, where N is an even number.
For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.
Find B_i for each i = 1, 2, ..., N.

-----Constraints-----
 - 2 \leq N \leq 200000
 - N is even.
 - 1 \leq X_i \leq 10^9
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
X_1 X_2 ... X_N

-----Output-----
Print N lines.
The i-th line should contain B_i.

-----Sample Input-----
4
2 4 4 3

-----Sample Output-----
4
3
3
4

 - Since the median of X_2, X_3, X_4 is 4, B_1 = 4.
 - Since the median of X_1, X_3, X_4 is 3, B_2 = 3.
 - Since the median of X_1, X_2, X_4 is 3, B_3 = 3.
 - Since the median of X_1, X_2, X_3 is 4, B_4 = 4.

Difficulty: introductory

Starter code:

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

y = sorted(x)

ans1 = y[n//2]
ans2 = y[n//2-1]

for i in x :
    if i < ans1 :
        print(ans1)
    else :
        print(ans2)


import bisect
n=int(input())
x=list(map(int,input().split()))
m=n//2
y=sorted(x)
for i in range(n):
  if bisect.bisect_right(y,x[i])>m:
    print(y[m-1])
  else:
    print(y[m])

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

for i in range(n):
    x[i] = (x[i], i)

x.sort()

answers = [x[n//2 - 1][0]] * n

ans = x[n//2][0]
for i in range(n//2):
    answers[x[i][1]] = ans

for i in answers:
    print(i)

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

n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
#m = y[n//2-1:n//2+1]
m_index = n//2-1
m = y[m_index]

for i in range(n):
  if x[i] <= m:
    print(y[m_index+1])
  else:
    print(y[m_index])

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

b=a[:]
a.sort()

one=a[n//2-1]
two=a[n//2]

def get_median(i):
    if b[i]<=one:
        return two
    return one

for i in range(n):
	print(get_median(i))

def main():
    n = int(input())
    x = [int(xn) for xn in input().split()]
    x_sorted = sorted(x)
    idx_median = n // 2
    median_low = x_sorted[idx_median - 1]
    median_high = x_sorted[idx_median]
    for xn in x:
        print((median_high if xn <= median_low else median_low))


def __starting_point():
    main()

__starting_point()

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

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

sxs = sorted(XS)
a1 = sxs[N//2-1]
a2 = sxs[N//2]

for i in range(N):
  x = XS[i]
  if x <= a1:
    print(a2)
  else:
    print(a1)


N = int(input())
N_List = list(map(int,input().split()))
N_List_Sorted = sorted(N_List)
B = N_List_Sorted[N//2]
A = N_List_Sorted[N//2 - 1]

if A == B:
    for i in range(N):
        print(A)
else:
    for i in range(N):
        if N_List[i] <= A:
            print(B)
        else:
            print(A)





n = int(input())
x = list(map(int,input().split()))
lis = sorted(x)
key1 = lis[n//2-1]
key2 = lis[n//2]
for i in x:
    if i > key1:
        print(key1)
    else:
        print(key2)


import statistics

n = int(input())
x = list(map(int, input().split()))
xmd = statistics.median(x)
xs = sorted(x)
for i in x:
    if i < xmd:
        print((xs[n // 2]))
    else:
        print((xs[n // 2 - 1]))


N = int(input())
A = list(map(int, input().split()))
AA = sorted(A)
X = AA[N//2 - 1]
Y = AA[N//2]
for i in range(N):
  if A[i] < Y:
    print(Y)
  if A[i] >= Y:
    print(X)

import numpy as np

N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
x = np.median(X)
index = N // 2
m1 = Y[index]
m2 = Y[index - 1]

for i in range(N):
    if X[i] < x:
        print(m1)
    else:
        print(m2)


import copy

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

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

x1 = x[N // 2 - 1]
x2 = x[N // 2]

for xx in X:
    if xx <= x1:
        print(x2)
    else:
        print(x1)

#51 C - Many Medians
N = int(input())
X = list(map(int,input().split()))
Xsrt = sorted(X,reverse = False)
XL = set(Xsrt[:N//2])
XR = set(Xsrt[N//2:])

ans = []
for x in X:
    if x in XR:
        ans.append(Xsrt[N//2-1])
    elif x in XL:
        ans.append(Xsrt[N//2])
for a in  ans:
    print(a)

import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return list(map(int, input().split()))
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    import statistics
    n = i_input()
    l = i_list()
    ml = min(l)
    Ml = max(l)
    ol = statistics.median(l)

    L = l.copy()

    L.remove(ml)
    pol = statistics.median(L)
    L.append(ml)

    L.remove(Ml)
    mol = statistics.median(L)
    L.append(Ml)

    ans = []

    for i in l:
        if i >= ol:
            ans.append(mol)
        else:
            ans.append(pol)

    for i in ans:
        print(i)



def __starting_point():
    main()

__starting_point()

N = int(input())
X_list = list(map(int, input().split()))
tmp = X_list.copy()

tmp.sort()
a = tmp[int(N/2)-1]
b = tmp[int(N/2)]
for i in range(N):
    if(X_list[i] <= a):
        print(b)
    else:
        print(a)

N = int(input())
X = list(map(int,input().split()))
x = sorted(X)
ms = x[N//2-1]
for i in range(N):
    if X[i] > ms:
        print(ms)
    else:
        print(x[N//2])

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

x = list(enumerate(X))

x.sort(key=lambda x: x[1])
A = list([x[1] for x in x[n//2-1:n//2+1]])

for v in X:
    if v <= A[0]:
        print((A[1]))
    else:
        print((A[0]))


# -*- coding: utf-8 -*-
"""
Created on Tue Sep 22 14:57:09 2020

@author: liang
"""

N = int(input())
X = [int(x) for x in input().split()]
Y = X.copy()
Y.sort()
upper = Y[N//2]
lower = Y[N//2-1]

for i in range(N):
    if X[i] < upper:
        print(upper)
    else:
        print(lower)

n = int(input())
x = list(map(int, input().split()))
y = sorted(x)
a = y[n // 2 - 1]
b = y[n // 2]
for i in x:
    print((a, b)[i <= a])

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

res1 = x[n//2]
res2 = x[n//2 -1]

for i in range(n):
  if X[i] >= res1:
    print(res2)
  elif X[i] <= res2:
    print(res1)

N=int(input())
*X,=map(int,input().split())
s=sorted(X)

t1=s[N//2-1]
t2=s[N//2]

for x in X:
    if x<=t1:
        print(t2)
    else:
        print(t1)

n=int(input())
x=list(map(int,input().split()))
st=sorted(x)
a=st[len(st)//2-1]
b=st[len(st)//2]

for i in x:
  if i<=a:
    print(b)
  else:
    print(a)


N, *X = list(map(int, open(0).read().split()))
sorted_X = sorted(X)
median_l = sorted_X[N // 2 - 1]
median_r = sorted_X[N // 2]

for x in X:
    if x < median_l:
        print(median_r)
    elif x == median_l:
        print(median_r)
    elif x == median_r:
        print(median_l)
    else:
        print(median_l)


#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
n = I()
X = readInts()
nya = sorted(X)
m1 = nya[n//2-1]
m2 = nya[n//2]
for x in X:
    if x <= m1:
        print(m2)
    else:
        print(m1)


import numpy
N = int(input())
X = [int(x) for x in input().split()]
S = sorted(X)
m0 = numpy.median(S[:-1])
m1 = numpy.median(S[1:])

for x in X:
    if x < m1:
        print((int(m1)))
    else:
        print((int(m0)))



N = int(input())
X = list(map(int, input().split()))
Xs = sorted(X)
c = int(N/2)
a, b = Xs[c-1], Xs[c]
for i in range(N):
	if X[i] <= a:
		print(b)
	else:
		print(a)

n = int(input())
X = list(map(int, input().split()))
s = sorted(X)

med_low = s[n//2 - 1]
med_high = s[n//2]

for x in X:
    if x <= med_low: print(med_high)
    else: print(med_low)

N = int(input())
X = [int(i) for i in input().split()]
Xs = list(sorted(X))
for x in X:
    if x > Xs[N // 2 - 1]:
        print((Xs[N // 2 - 1]))
    else:
        print((Xs[N // 2]))


n = int(input())
x = list(map(int, input().split()))
w = tuple(x)
x.sort()
if x[(n//2)-1] == x[n//2]:
    for i in range(n):
        print(x[n//2])
else:
    for h in w:
        if h <= x[(n//2)-1]:
            print(x[n//2])
        else:
            print(x[(n//2)-1])

N = int(input())
Xls = list(map(int,input().split()))
X2ls = sorted(Xls)
M1 = X2ls[N//2-1]
M2 = X2ls[N//2]
lsans = []
for i in range(N):
    if Xls[i] <= M1:
        M = M2
    else:
        M = M1
    lsans.append(M)
for i in lsans:
    print(i)

#!/usr/bin/env python
import sys 
import copy
input = sys.stdin.readline

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

l = xx[(n-1)//2]
r = xx[n//2]
mid = (l+r)/2

for i in range(n):
    if x[i] >= mid:
        print(l)
    else:
        print(r)


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

c = sorted(b, reverse=True)

m = int(a / 2) - 1
anslist = [0] * a
for i, data in enumerate(b):
    if c[m] > data:
        anslist[i] = c[m]
    elif c[m] <= data:
        anslist[i] = c[m + 1]
        
for j in range(a):
    print(anslist[j])

n = int(input())
x = list(map(int, input().split()))
x_sort = sorted(x)
half_l = x_sort[(n-1)//2]
half_r = x_sort[(n)//2]

for i in range(n):
    if x[i] <= half_l:
        print(half_r)
    else:
        print(half_l)


n = int(input())
x = list(map(int,input().split()))
xs = sorted(x)
m = (xs[n//2]+xs[n//2-1])/2
for i in range(n):
    if x[i]<=m:
        print(xs[n//2])
    else:
        print(xs[n//2-1])

N = int(input())
X = list(map(int, input().split()))
X_sorted = sorted(X)
pre_med_index = (N // 2) - 1
pos_med_index = N // 2
import bisect

for i in range(N):
    if X[i] <= X_sorted[pre_med_index]:
        print((X_sorted[pos_med_index]))
    else:
        print((X_sorted[pre_med_index]))


import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n = ini()
    x = inl()
    y = sorted(x)

    p = y[n // 2 - 1]
    q = y[n // 2]

    for i in range(n):
        if x[i] < q:
            print(q)
        else:
            print(p)


solve()


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

from decimal import Decimal

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

y = x.copy()

y.sort()

m1 = y[n//2]
m2 = y[n//2 - 1]
m = Decimal(m1 + m2) / Decimal(2) 
#print(m1, m2)

for z in x:
    if z <= m:
        print(m1)
    else:
        print(m2)

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)
  else:
    print(B)

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

x_sort = sorted(x)
lenth = len(x)
low = x_sort[int(lenth/2)-1]
high = x_sort[int(lenth/2)]

for y in x:
    if y <= low:
        print(high)
    else:
        print(low)

n = int(input())
x = list(map(int,input().split()))
y = x.copy()
y.sort()
z = set(x)
t1 = y[n//2-1]
t2 = y[n//2]
idx = dict([])
idx[y[0]] = 0
l = y[0]
cnt = 0
for i in y:
    if i == l:
        cnt += 1
        continue
    else:
        idx[i] = cnt
        l = i
        cnt += 1

for i in x:
    t = idx[i]
    if t<n//2:
        print(t2)
    else:
        print(t1)

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

tmpx=sorted(xlist)
med1,med2 = tmpx[n//2-1],tmpx[n//2]
# print(x)
# print(med1,med2)

for x in xlist:
    if x<=med1:
        print(med2)
    else:
        print(med1)



import statistics
n=int(input())
x=list(map(int,input().split()))
y=statistics.median(x)
xs=sorted(x)
for i in x:
    if i<y:
        print((xs[n//2]))
    else:
        print((xs[n//2-1]))
        


N=int(input())
*X,=map(int,input().split())
s=sorted(X)
 
t1=s[N//2-1]
t2=s[N//2]
 
for x in X:
    if x<=t1:
        print(t2)
    else:
        print(t1)

import copy
n = int(input())
a = [int(x) for x in input().split()]
b = copy.copy(a)
b.sort()
m = (b[n//2] + b[n//2 - 1]) // 2
for i in range(n):
  if m < a[i]:
    print((b[n//2 - 1]))
  else:
    print((b[n//2]))


N=int(input())
X=list(map(int,input().split()))
import copy
Y=copy.copy(X)
Y.sort()

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


N = int(input())
X = list(map(int, input().split()))
org = X.copy()

X.sort()

right = int(N // 2)
left = right - 1

med = (X[left] + X[right]) / 2

for x in org:
    if x >= med:
        print((X[left]))
    else:
        print((X[right]))


n=int(input())
x=list(map(int,input().split()))
ans=sorted(x)
ans2=ans[n//2-1]
ans1=ans[n//2]

for i in range(n):
  if x[i]>=ans[n//2]:
    print(ans2)
  else:
    print(ans1)


N = int(input())
X = list(map(int, input().split()))
med1 = sorted(X)[N // 2 - 1]
med2 = sorted(X)[N // 2]
for i in range(N):
    tmp = X[i]
    if tmp <= med1:
        print(med2)
    else:
        print(med1)


import numpy as np

N = int(input())
xl = [int(x) for x in input().split()]

xlsorted = np.sort(xl)
m1 = xlsorted[int(N/2)-1]
m2 = xlsorted[int(N/2)]

for i in range(N):
    if xl[i] <= m1:
        print(m2)
    else:
        print(m1)


N = int(input())
a = list(map(int,input().split()))
s = list(sorted(a))
ind = {}
for i in range(N):
    if s[i] not in ind:
        ind[s[i]] = i
for i in range(N):
    if ind[a[i]] < N//2:
        print(s[N//2])
    else:
        print(s[N//2-1])

n = int(input())
x = list(map(int,input().split()))
x_2 = sorted(x)
m_1 = x_2[n//2-1]
m_2 = x_2[n//2]
for i in range(n):
    if x[i] <= m_1:
        print(m_2)
    elif x[i] >= m_2:
        print(m_1)



n = int(input())
x = list(map(int,input().split()))
l = sorted(x)
ans_1 = l[n//2 - 1]
ans_2 = l[n//2]
for i in x:
  if i <= ans_1:
    print(ans_2)
  else:
    print(ans_1)


import bisect

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

sorted_x = sorted(X)

l, r = sorted_x[n//2], sorted_x[n//2-1]

for x in X:
    if bisect.bisect_left(sorted_x, x) < n // 2:
        print(l)
    else:
        print(r)

def getval():
    n = int(input())
    x = list(map(int,input().split()))
    return n,x 

def main(n,x):
    y = sorted(x)
    a,b = y[(n-1)//2],y[(n-1)//2+1]
    for i in x:
        if i>a:
            print(a)
        else:
            print(b)

def __starting_point():
    n,x = getval()
    main(n,x)
__starting_point()

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

m1=Y[N//2-1]
m2=Y[N//2]

medians = [m2 if x < m2 else m1 for x in X]
print('\n'.join(map(str,medians)))

import math
import statistics

n = int(input())
xL = list(map(int, input().split(" ")))

xL2 = []
for i in range(n):
    xL2.append([i, xL[i]])
xL2 = sorted(xL2, key=lambda x: x[1])

if n % 2 == 0:
    center = n // 2
    centers = [xL2[center - 1], xL2[center]]
    for i in range(n):
        if i == centers[0][0] or i == centers[1][0]:
            print(statistics.median(xL[:i] + xL[i + 1:]))
        else:
            if centers[0][1] < xL[i]:
                print(centers[0][1])
            else:
                print(centers[1][1])
else:
    center = n // 2
    centers = [xL2[center - 1], xL2[center], xL2[center + 1]]
    for i in range(n):
        if i == centers[0][0] or i == centers[1][0] or i == centers[2][0]:
            print(statistics.median(xL[:i] + xL[i + 1:]))
        else:
            if centers[0][1] < xL[i]:
                print((centers[0][1] + centers[1][1]) / 2)
            else:
                print((centers[1][1] + centers[2][1]) / 2)

n = int(input())
x = list(map(int, input().split()))
x2 = sorted(x)
mid = n//2-1
for i in range(n):
    xi = x[i]
    if x2[mid] < xi:
        print((x2[mid]))
    else:
        print((x2[mid+1]))


def main():
    n = int(input())
    x_lst = list(map(int, input().split()))
    x_sorted_lst = sorted(x_lst)

    median1 = x_sorted_lst[n // 2 - 1]
    median2 = x_sorted_lst[n // 2]

    if median1 == median2:
        lst = [median1] * n

    else:
        lst = []
        for i in range(n):
            x = x_lst[i]

            if x <= median1:
                lst.append(median2)
            elif median2 <= x:
                lst.append(median1)

    for i in range(n):
        print(lst[i])


def __starting_point():
    main()
__starting_point()

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

nums = sorted(x)
m1 = n//2-1
m2 = n//2
for i in range(n):
  if x[i] <= nums[m1]: print(nums[m2])
  elif nums[m2] <= x[i]: print(nums[m1])

import copy

def main():
	N = int(input())
	X = [int(x) for x in input().split(" ")]
	sortedX = copy.deepcopy(X)
	sortedX.sort()
	cand = [sortedX[int(N / 2) - 1], sortedX[int(N / 2)]]

	for xi in X:
		if xi <= cand[0]:
			print((cand[1]))
		else:
			print((cand[0]))

main()


N = int(input())
x = list(map(int, input().split()))
a = sorted(x)
p = int(N/2)-1
l = a[p]
for i in range(N):
  n = p
  if x[i] <= l:
    n = p+1
  print(a[n])

N = int(input())
X = list(map(int,input().split()))
Y = sorted(X)
med = (Y[N//2] + Y[N//2-1])/2
for i in range(N):
    if X[i] <= med:
        print(Y[N//2])
    else:
        print(Y[N//2-1])

import copy
n = int(input())
x = list(map(int,input().split()))
a = copy.deepcopy(x)
x.sort()
for i in range(n):
    if x[int(n/2)-1]<a[i]:
        print((x[int(n/2)-1]))
    else:
        print((x[int(n/2)]))


def main():
    N = int(input())
    X = list(map(int, input().split()))
    Y = X.copy()
    Y.sort()

    if N%2 == 0:
        mid1 = Y[N//2]
        mid2 = Y[N//2-1]
        for x in X:
            if x <= mid2:
                print(mid1)
            else:
                print(mid2)
        return

def __starting_point():
    main()

__starting_point()

# import itertools
# import math
# from functools import reduce
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np
# import heapq
# from collections import deque
import copy

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
X = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# 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

#def make_divisors(n):
#    lower_divisors , upper_divisors = [], []
#    i = 1
#    while i*i <= n:
#        if n % i == 0:
#            lower_divisors.append(i)
#            if i != n // i:
#                upper_divisors.append(n//i)
#        i += 1
#    return lower_divisors + upper_divisors[::-1]

# def gcd_list(numbers):
#     return reduce(math.gcd, numbers)

# if gcd_list(A) > 1:
#     print("not coprime")
#     return

# 高速素因数分解準備
#MAXN = 10**6+10
#sieve = [i for i in range(MAXN+1)]
#p = 2
#while p*p <= MAXN:
#    if sieve[p] == p:
#        for q in range(2*p, MAXN+1, p):
#            if sieve[q] == q:
#                sieve[q] = p
#    p += 1

X = [[i, x] for i, x in enumerate(X)]
X = sorted(X, reverse=False, key=lambda x:x[1])
X_ranked = copy.copy(X)
X = [[l[0], i, l[1]] for i, l in enumerate(X)]
X = sorted(X, reverse=False, key=lambda x:x[0])

med = len(X) // 2

for l in X:
    if l[1] < med:
        print((X_ranked[med][1]))
    else:
        print((X_ranked[med - 1][1]))


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

m = n // 2
p = y[m - 1]
q = y[m]
for i in range(n):
    if p < x[i]:
        print(p)
    else:
        print(q)

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

mid_ls = [sort_X[N//2-1],sort_X[N//2]]

for i in range(N):
  if X[i] >= mid_ls[1]:
    print(mid_ls[0])
  else:
    print(mid_ls[1])

import copy
N = int(input())
X = list(map(int, input().split()))
Xsort = copy.copy(X)
Xsort.sort()
centerR = Xsort[N//2]
centerL = Xsort[N//2-1]
for i in range(N):
    if X[i] >= centerR:
        print(centerL)
    else:
        print(centerR)


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

a = x2[n//2 - 1]
b = x2[n//2]

for i in range(n):
    if x[i] <= a:
        print(b)
    else:
        print(a)

#!/usr/bin/env python3

import numpy as np


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

median = np.median(x)
x_sorted = sorted(x)

index = len(x)//2-1

for i in x:
    if i == median:
        print(i)
    elif i < median:
        print((x_sorted[index+1]))
    else:
        print((x_sorted[index]))


N=int(input())
X=list(map(int,input().strip().split()))

Y=sorted(X)
a=Y[N//2-1]
b=Y[N//2]
for n in range(N):
    if X[n]<=a:
        print(b)
    else:
        print(a)

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


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

from copy import copy
n, *x = list(map(int, open(0).read().split()))
a = []
for i, v in enumerate(x):
    a.append((v, i))
a.sort()

# a[(i - 1)/ /2] , a[i // 2]
ans = [0] * n
for i in range(n):
    if i <= (n - 1) // 2:
        ans[a[i][1]] = a[n // 2][0]
    else:
        ans[a[i][1]] = a[(n - 1) // 2][0]
for y in ans:
    print(y)


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

p,q=A[N//2-1:N//2+1]

for i in List:
  print(p if i>=q else q)

import copy
N = int(input())
X = list(map(int, input().split()))
tmp_X = copy.deepcopy(X)
tmp_X.sort()
m1 = tmp_X[N // 2]
m2 = tmp_X[N // 2 - 1]
for x in X:
    if x < m1:
        print(m1)
    else:
        print(m2)

import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return list(map(int,input().split()))
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
x = l()
p=sorted(x)
mid = len(p)//2
for i in x:
    a = bisect.bisect(p,i)
    if a <= mid:
        print((p[mid]))
    else:
        print((p[mid-1]))


'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import copy
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  t=(N+1)//2
  Y=sorted(X)
  ans1=Y[t-1]
  ans2=Y[t]
  median=ans1+ans2
  for i in range(N):
    s=X[i]
    if s==ans1:
      print(ans2)
    elif s==ans2:
      print(ans1)
    elif  2*s<median:
      print(ans2)
    elif 2*s>median:
      print(ans1)
  return 

main()

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

sorted_x = sorted(X)

l, r = sorted_x[n//2-1], sorted_x[n//2]

for x in X:
    if x < r:
        print(r)
    else:
        print(l)

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

y = sorted(x)
a = y[len(x)//2]
b = y[(len(x)//2) - 1]

for i in range(n):
    if x[i] <= b:
        print(a)
    else:
        print(b)


import statistics
n = int(input())
X = list(map(int, input().split()))
X_ = sorted(X)
med = X_[n//2-1]
med_2 = X_[n//2]
for i in range(n):
    if X[i]>med:
        print(med)
    else:
        print(med_2)

n = int(input())
xn = list(map(int, input().split()))
xn_s = sorted(xn)
m1 = xn_s[n//2 - 1]
m2 = xn_s[n//2]
for x in xn:
    if x <= m1:
        print(m2)
    else:
        print(m1)

n = int(input())
x = list(map(int, input().split()))
y = sorted(x)
a = y[n // 2 - 1]
b = y[n // 2]
for i in x:
    print((a, b)[i <= a])

N = int(input())
X = list(map(int,input().split()))
a = sorted(X)[N//2-1]
b = sorted(X)[N//2]

if a == b:
  for _ in range(N):
    print(a)
else:
  for i in range(N):
    if X[i] <= a:
      print(b)
    else:
      print(a)

#!/usr/bin/env python3

def main():
    n = int(input())
    x = list(map(int, input().split()))
    ans = [0] * n
    x_sort = sorted(x)
    a = x_sort[1:n]
    a_med = a[n // 2 - 1]
    b = x_sort[0:n - 1]
    b_med = b[n // 2 - 1]
    for i in range(n):
        if x[i] < a_med:
            ans[i] = a_med
        else:
            ans[i] = b_med

    print(*ans, sep='\n')


def __starting_point():
    main()

__starting_point()

from copy import *

N=int(input())
X=list(map(int,input().split()))
Y=deepcopy(X)
Y.sort()
mid1=Y[N//2-1]
mid2=Y[N//2]
for i in range(N):
  if X[i]<=mid1:
    print(mid2)
  else:
    print(mid1)


n=int(input())
x=list(map(int,input().split()))
for i in range(n):
  x[i] = [x[i], i]
x.sort(key=lambda x:x[0])
for i in range(n):
  if i < n//2:
    x[i] += [x[n//2][0]]
  else:
    x[i] += [x[n//2-1][0]]
# x[i] = [value, init_index, b_i]
x.sort(key=lambda x:x[1])
for i in range(n):
  print(x[i][2])

n = int(input())
xx = list(map(int, input().split()))
yy = sorted(xx)

a = yy[n//2-1]
b = yy[n//2]

for x in xx:
  if x <= a:
    print(b)
  elif x >= b:
    print(a)

n = int(input())

x = list(map(int, input().split()))
x_sorted = sorted(x)
med_low = x_sorted[(n // 2) - 1]
med_upper = x_sorted[(n // 2)]

for i in range(n):
    if x[i] <= med_low:
        print(med_upper)
    else:
        print(med_low)


import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: list(map(int, sys.stdin.readline().split()))
inintl = lambda: list(inintm())
instrm = lambda: list(map(str, sys.stdin.readline().split()))
instrl = lambda: list(instrm())


n = inint()
X = inintl()

X_sorted = sorted(X)

a, b = X_sorted[n//2-1],X_sorted[n//2]

for x in X:
    if x <= a:
        print(b)
    else:
        print(a)


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

sorted_lst = sorted(lst)
mini = sorted_lst[(n//2)-1]
maxi = sorted_lst[(n//2)]
for i in lst:
    if i <= mini:
        print(maxi)
    else:
        print(mini)

n = int(input())
l = list(map(int,input().split()))
sorted_list = sorted(l)
left = sorted_list[n//2-1]
right = sorted_list[n//2]
for i in l:
    if i <= left:
        print(right)
    else:
        print(left)

n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
index = n//2

for i in range(n):
  print(y[-index] if x[i]<y[index] else y[-index-1])

import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return list(map(int, stdin.readline().split()))
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    X = nl()
    X_s = sorted(X)
    mid = X_s[n // 2]
    del_mid = (X_s[:n // 2] + X_s[n // 2 + 1:])[(n - 1) // 2]
    for x in X:
        if x < mid:
            print(mid)
        elif x > mid:
            print((X_s[n // 2 - 1]))
        else:
            print(del_mid)


def __starting_point():
    main()

__starting_point()

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