Problem:
 Score : 300 points    Problem Statement 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 1 4
2 4 4 3      Sample Output 1 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 .        Sample Input 2 2
1 2      Sample Output 2 2
1       Sample Input 3 6
5 5 4 4 3 3      Sample Output 3 4
4
4
4
4
4

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

sort_x=sorted(x)

left_num=sort_x[n//2-1]
right_num=sort_x[n//2]
for i in range(n):
  if x[i]<=left_num:
    print(right_num)
  else:
    print(left_num)

Solution (Python):
n = int(input())
A = [int(i) for i in input().split()]
sortA = sorted(A)
med = sortA[n // 2]

for i in range(n):
    if A[i] < med:
        print(med)
    else:
        print(sortA[n // 2 - 1])

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

Y = sorted(X)

Bright = Y[N//2]
Bleft = Y[N//2-1]

for i in X:
    if i<=Bleft:
        print(Bright)
    else:
        print(Bleft)

Solution (Python):


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

    Y = sorted(X)
    m0, m1 = Y[int(N / 2) - 1], Y[int(N / 2)]

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


if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
A = [int(i) for i in input().split()]
sortA = sorted(A)

for i in range(N):
    if A[i] < sortA[N//2]:
        print(sortA[N//2])
    else:
        print(sortA[N//2 - 1])

Solution (Python):
N = int(input())
x = {}
ans = {}
y = []
k = 1
l = 1
for i in list(map(int,input().split())):
    x[k] = i
    y.append(i)
    k += 1

y.sort()
m_1 = y[int(N/2)]
m_2 = y[int(N/2)-1]

for i,j in sorted(x.items(),key = lambda x: x[1]):
    if (int(N/2) >= l):
        ans[i] = m_1
        l+=1
    else:
        ans[i] = m_2
        l+=1

for i,j in sorted(ans.items()):
    print(j)

Solution (Python):
n = int(input())
A = [int(i) for i in input().split()]
sortA = sorted(A)

for i in range(n):
    if A[i] < sortA[n//2]:
        print(sortA[n//2])
    else:
        print(sortA[n//2 - 1])

Solution (Python):
N = int(input())
X = [int(i) for i in input().split()]
x = sorted(X)
num1 = x[N//2]
num2 = x[N//2 - 1]
ans = []
for i in X:
    if i <= num2:
        ans.append(num1)
    else:
        ans.append(num2)
for i in ans:
    print(i)

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
import copy
Y = copy.deepcopy(X)
Y.sort()
a = Y[int(N/2)-1]
b = Y[int(N/2)]
for i in range(N):
    if X[i] <= a:
        print(b)
    else:
        print(a)

Solution (Python):
n = int(input())
X = [int(i) for i in input().split()]
sortX = sorted(X, reverse=True)
m1 = sortX[n // 2 - 1]
m2 = sortX[n // 2]

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

Solution (Python):
import statistics
N = list(map(int,input().split()))
l = list(map(int,input().split()))

a = statistics.median_low(l)
b = statistics.median_high(l)

for i in l:
  if i <= a:
    print(b)
  elif i >= b:
    print(a)

Solution (Python):


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

aN2 = sorted(aN)

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

Solution (Python):
n = int(input())
A = [int(i) for i in input().split()]

sortA = sorted(A)
mid = sortA[n//2 - 1]
midnext = sortA[n//2]

for i in range(n):
    if A[i] <= mid:
        print(midnext)
    else:
        print(mid)

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
y = list(x)
y.sort()
if n % 2 != 0:
    a,b,c = y[n//2-1],y[n//2],y[n//2+1]
    m = b
else:
    a,b = y[n//2-1],y[n//2]    
    m = (a+b)/2
for i in range(n):
    if i == n//2:
        if n%2==0:
            tm = a
        else:
            tm = (a+c)/2
    if x[i] < m :
        if n%2==0:
            tm = b
        else:
            tm = (b+c)/2
    else:
        if n%2==0:
            tm = a
        else:
            tm = (a+b)/2
    print(int(tm))

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

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
sortA = sorted(A)

for i in range(n):
    if A[i] <= sortA[(n // 2) - 1]:
        print(sortA[n // 2])
    else:
        print(sortA[(n // 2) - 1])

Solution (Python):
import math
n = int(input())
X = list(map(int,input().split()))
x = sorted(X)

left = x[math.floor((n-1)/2)]
right = x[math.ceil((n-1)/2)]

for a in X:
    if a < right:
        print(right)
    else:
        print(left)

Solution (Python):
N = int(input())
inputs = [int(i) for i in input().split()]

sorted_inputs = inputs[:]
sorted_inputs.sort()
left = sorted_inputs[N//2-1]
right = sorted_inputs[N//2]

for item in inputs:
    if item <= left:
        print(right)
    else:
        print(left)

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

b=sorted(a)

for i in range(n):
  if a[i]<=b[int(n/2)-1]:
    print(b[int(n/2)])
  else:
    print(b[int(n/2)-1])

Solution (Python):
n = int(input())
x = list(map(int,input().split()))
y =[]
for i in range(n):
    y.append([x[i],i])
y.sort(key = lambda x:x[0])
ans1 =y[n//2][0]
ans2 =y[n//2-1][0]

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

Solution (Python):
def main():
    n = int(input())
    xs = list(map(int, input().split()))
    i_m = n // 2 - 1
    ys = sorted((x, i) for i, x in enumerate(xs))
    for x in xs:
        if x <= ys[i_m][0]:
            print(ys[i_m + 1][0])
        else:
            print(ys[i_m][0])


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
X = [int(i) for i in input().split()]
X2 = sorted(X)
mapper = {}

for i in range(N//2) :
    if (X2[i] in mapper) :
        continue
    mapper[X2[i]] = X2[len(X2)//2]

for i in range(N//2,N) :
    if (X2[i] in mapper) :
        continue
    mapper[X2[i]] = X2[(len(X2)//2) - 1]

for x in X :
    print(mapper[x])

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
c = sorted(a)
mid1 = c[n//2-1]
mid2 = c[n//2]
if mid1 == mid2:
  for i in range(n):
    print(mid1)
  exit()
for i in range(n):
  if a[i] <= mid1:
    print(mid2)
  else:
    print(mid1)

Solution (Python):
N = int(input())
x = list(map(int, input().split()))
xx = sorted(x)
med1,med2 = xx[N//2-1], xx[N//2]

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

Solution (Python):
n = (int)(input())
l = (list)(map(int, input().split()))

tmp = l.copy()
tmp.sort()

left = tmp[n//2-1]
right = tmp[n//2]

for item in l:
    if item <= left:
        print(right)
    else:
        print(left)

Solution (Python):
import copy
def main():
    n = int(input())
    x = list(map(int,input().split()))

    a = copy.deepcopy(x)
    a.sort()
    a1 = a[(n-1)//2]
    a2 = a[(n+1)//2]

    for i in range(0,n):
        if x[i]<=a1:
            print(a2)
        else:
            print(a1)

if __name__ == "__main__":
    main()

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

if n == 2:
    print(x[1])
    print(x[0])
else:
    y = sorted(x)
    m1 = y[int(n/2)-1]
    m2 = y[int(n/2)]
    if m1 == m2:
        for _ in range(n):
            print(m1)
    else:
        for i in range(n):
            if x[i] <= m1:
                print(m2)
            elif x[i] >= m2:
                print(m1)

Solution (Python):
import copy
n = int(input())
xarray = list(map(int,input().split()))
newArray = copy.copy(xarray)
newArray.sort()

left = newArray[n//2-1]
right = newArray[n//2]


for item in xarray:
    if item<=left:  
        print(right)
    else:
        print(left)

Solution (Python):
n = int(input())
xarray = list(map(int,input().split()))
newArray = xarray[:]
newArray.sort()

left = newArray[n//2-1]
right = newArray[n//2]


for item in xarray:
    if item<=left:
        print(right)
    else:
        print(left)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
XX = list(X)

X.sort()
left = X[N // 2 - 1]
right = X[N // 2]

if left == right:
    for i in range(N):
        print(left)
    exit()

for x in XX:
    if x <= left:
        print(right)
    else:
        print(left)

Solution (Python):

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

X_sort = sorted(X)
m = X_sort[N // 2]

for i, Xi in enumerate(X):
    if N % 2:
        if Xi <= m: print(X_sort[N // 2 + 1])
        else: print(m)
    else:
        if Xi >= m: print(X_sort[N // 2 - 1])
        else: print(m)

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

Solution (Python):
n = int(input())
arr = list(map(int,input().split()))

tarr = list(arr)

tarr.sort()

num1 = tarr[len(tarr) // 2 - 1]
num2 = tarr[len(tarr) // 2]

for i in range(n):
    if arr[i] < num2:
        print(num2)
    else:
        print(num1)

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

x_sorted = sorted(x)

med = (x_sorted[int(n/2)-1] + x_sorted[int(n/2)])/2

for i in range(n):
    if x[i]<med:
        print(x_sorted[int(n/2)])
    else:
        print(x_sorted[int(n/2)-1])

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

Solution (Python):
N = int(input())
X = [int(_) for _ in input().split()]
Y = sorted([[_, X[_]] for _ in range(N)], key=lambda x: x[1])
Z = [0] * N
a = Y[(N - 1) // 2][1]
b = Y[N // 2][1]
for i in range(N):
    Z[Y[i][0]] = b if i < N // 2 else a
[print(_) for _ in Z]

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
median1 = b[int(n/2)-1]
median2 = b[int(n/2)]
for i in a:
    if i <= median1:
        print(median2)
    else:
        print(median1)

Solution (Python):
n = int(input())
x = list(map(int,input().split()))
x_sort = sorted(x)

meds = x_sort[n//2-1:n//2+1]

for i in x:
    if i <= meds[0]:
        print(meds[1])
    else:
        print(meds[0])

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
X_sort = X.copy()
X_sort.sort()
s = N // 2
median = (X_sort[s - 1] + X_sort[s]) / 2

for x in X:
    if x < median:
        print(X_sort[s])
    else:
        print(X_sort[s-1])

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
big = sorted(a)[N // 2]
sma = sorted(a)[N // 2 - 1]
if big == sma:
    for i in range(N):
        print(big)
else:
    for i in a:
        if i < big:
            print(big)
        else:
            print(sma)

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
Y = sorted(X)
n = int(N/2) 
for e in X:
    if e <= Y[n-1]:
        print(Y[n])
    elif e >= Y[n]:
        print(Y[n-1])

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

X = [{'idx': i, 'ord': -1, 'val': int(x)} for i, x in enumerate(input().split())]

order = sorted(X, key=lambda x: x['val'])

for i in range(N):
    X[order[i]['idx']]['ord'] = i

for x in X:
    if (x['ord'] < N / 2):
        bi = N // 2
    else:
        bi = (N - 2) // 2
    print(order[bi]['val'])

Solution (Python):
iN = int(input())
aX = [int(_) for _ in input().split()]
aXs = sorted(aX)

iMu  = iN//2
iMd  = iN//2 -1

iMuV = aXs[iMu]
iMdV = aXs[iMd]

if iMuV == iMdV:
    print("\n".join([str(iMuV)]*iN))
else:
    print("\n".join(map(str,map(lambda x: iMuV if x < iMuV else iMdV ,aX))))

Solution (Python):
iN = int(input())
aX = [int(_) for _ in input().split()]

aXs = sorted(enumerate(aX),key=lambda x:x[1])

iMu  = iN//2
iMd  = iN//2 -1

iMuV = aXs[iMu][1]
iMdV = aXs[iMd][1]

if iMuV == iMdV:
    print("\n".join([str(iMuV)]*iN))
else:
    print("\n".join(map(str,map(lambda x: iMuV if aX[x] < iMuV else iMdV ,range(iN)))))

Solution (Python):
iN = int(input())
aX = [int(_) for _ in input().split()]

aXs = sorted(enumerate(aX),key=lambda x:x[1])

iMu  = iN//2
iMd  = iN//2 -1

iMuV = aXs[iMu][1]
iMdV = aXs[iMd][1]

if iMuV == iMdV:
    print("\n".join([str(iMuV)]*iN))
else:
    print("\n".join(map(str,(map(lambda x: iMuV if aX[x] < iMuV else iMdV ,range(iN))))))

Solution (Python):
import sys
input=sys.stdin.readline
import math

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

Solution (Python):
N = int(input())
X = [int(_) for _ in input().split()]

X2 = sorted(X)
r = X2[N // 2 ]
l = X2[N // 2 -1]

for i in range(N):
    if X[i] <  r:
        print(r)
    else:
        print(l)

Solution (Python):
import bisect

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

X2 = sorted(X)
r = X2[N // 2 ]
l = X2[N // 2 -1]

for i in range(N):
    if bisect.bisect_left(X2, X[i]) < N // 2:
        print(r)
    else:
        print(l)

Solution (Python):
n=int(input())
X=list(map(int,input().split()))
Y=sorted(X)

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

Solution (Python):
import numpy as np
N= int(input())
a = list(map(int, input().split(' ')))
sort_a = sorted(a)
small = sort_a[N//2-1]
big = sort_a[N//2]
for aa in a:
    if aa < big:
        print(big)
    else:
        print(small)

Solution (Python):
N = int(raw_input())
X_list = map(int, raw_input().split())

sorted_x = sorted(X_list)

small = sorted_x[N/2-1]
big = sorted_x[N/2]

for x in X_list:
    if x < big:
        print big
    else:
        print small

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
idx = range(N)
Y = [ [ idx[i], X[i]] for i in range(N) ]
Z = sorted(Y , key=lambda x: x[1])
ans = []
for i,j in enumerate(Z):
    idx_tmp = Z[i][0]
    if i < int(N/2):
        median = Z[int(N/2)][1]
    else:
        median = Z[int(N/2)-1][1]
    ans.append([idx_tmp,median])
ans = sorted(ans, key=lambda x:x[0])
for i in ans:
    print(i[1])

Solution (Python):
N = int(input())
X = [int(x) for x in input().split()]
_X = sorted([x for x in X])
x1 = _X[N // 2 - 1]
x2 = _X[N // 2]
for x in X:
  print(x2 if x <= x1 else x1)

Solution (Python):
N = int(input())
X = [int(x) for x in input().split()]

XS = sorted(X)

r = len(X) // 2
l = r - 1

lv = XS[l]
for n in X:
    print(XS[r if n <= lv else l])

Solution (Python):
N = int(input())
X = [int(x) for x in input().split()]
_X = [x for x in X]
_X.sort()
x1 = _X[N // 2 - 1]
x2 = _X[N // 2]
for x in X:
  print(x2 if x <= x1 else x1)

Solution (Python):
import copy
import statistics
n = int(input())
x = [int(y) for y in input().split()]
z = copy.deepcopy(x)
z.sort()
t = (z[int(n / 2) - 1] + z[int(n / 2)]) / 2

for i in range(n):
  if x[i] < t:
    print(z[int(n / 2)])
  else:
    print(z[int(n / 2) - 1])

Solution (Python):
from statistics import median
n = int(input())
x = list(map(int,input().split()))
xcopy = x.copy()
x.sort()
med = median(x)
for i in xcopy:
    if i < med:
        print(x[len(x)//2])
    else:
        print(x[len(x)//2 -1])

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

Solution (Python):
def main():
    n = int(input())
    x = [int(s) for s in input().split()]
    y = sorted(x)

    th = y[n // 2]
    for a in x:
        if a < th:
            print(y[n // 2])
        else:
            print(y[n // 2 - 1])

main()

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
y = sorted(x)
m1 = y[int(n/2-1)]
m2 = y[int(n/2)]
if m1==m2:
  for i in x:
    print(m1)
else:
  for i in x:
    if m2 > i:
      print(m2)
    elif i > m1:
      print(m1)

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

x2 = x.copy()
x2.sort()
c1 = x2[n // 2 - 1]
c2 = x2[n // 2]
for i in x:
    if(c1 >= i):
        print(c2)
    else:
        print(c1)

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

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
a = sorted(x)
ml = a[n//2-1]
mr = a[n//2]

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

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

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

sx = list(sorted(X))
m1 = sx[N//2 - 1]
m2 = sx[N//2]

ans = []
for a in X:
    if a >= m2:
        ans.append(m1)
    else:
        ans.append(m2)
print(*ans, sep='\n')

Solution (Python):


import sys


input = sys.stdin.readline


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


N = int(input())
X = inpl()
A = sorted(X)
mid = A[N//2]

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

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
x = list(li())

med1 = sorted(x)[n//2 - 1]
med2 = sorted(x)[n//2]

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

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

Solution (Python):
import copy
N = int(input())
X = [int(i) for i in input().split()]
Y = copy.deepcopy(X)
Y.sort()

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

Solution (Python):
import numpy as np
N = int(input())
X = np.array(list(map(int, input().split())), dtype=int)
idx = np.argsort(X)
Xs = np.sort(X)
ans = [None for _ in range(N)]
for i in range(N // 2):
    ans[idx[i]] = Xs[N // 2]
for i in range(N // 2, N):
    ans[idx[i]] = Xs[N // 2 - 1]
for i in range(N):
    print(ans[i])

Solution (Python):
import numpy as np
N = int(input())
X = np.array(list(map(int, input().split())), dtype=int)
idx = np.argsort(X)
Xs = X[idx]
ans = [None for _ in range(N)]
for i in range(N // 2):
    ans[idx[i]] = Xs[N // 2]
for i in range(N // 2, N):
    ans[idx[i]] = Xs[N // 2 - 1]
for i in range(N):
    print(ans[i])

Solution (Python):

N=int(input())
X=list(map(int, input().split()))
X_sorted=sorted(X)
small=X_sorted[int(N/2)-1]
large=X_sorted[int(N/2)]

for i in range(N):
    if X[i]<=small:
        print(large)
    else:
        print(small)

Solution (Python):
n = int(input())
x = [int(_) for _ in input().split()]
l = sorted(x)
m1 = l[n//2 - 1]
m2 = l[n//2]
for i in range(n):
    if x[i] <= m1:
        print(m2)
    else:
        print(m1)

Solution (Python):
import statistics


n = int(input())
x = [int(_) for _ in input().split()]
m1 = statistics.median_low(x)
m2 = statistics.median_high(x)
for i in range(n):
    if x[i] <= m1:
        print(m2)
    else:
        print(m1)

Solution (Python):
import copy
N = int(input())
X = list(map(int,input().split(" ")))
Y = copy.deepcopy(X)
Y.sort()
B = (Y[N//2]+Y[N//2-1])/2

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

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

Solution (Python):

N = int(input())
xn = list(map(int, input().split()))
xn_sorted = sorted(xn)
val_a = xn_sorted[(len(xn_sorted))//2 - 1]
val_b = xn_sorted[(len(xn_sorted))//2]

for xi in xn:
    if xi <= val_a:
        print(val_b)
    else:
        print(val_a)

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

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

x_sorted = sorted(x)
meds = x_sorted[n//2-1:n//2+1]
for i in range(n):
    if x[i] <= meds[0]:
        print(meds[1])
    elif x[i] >= meds[1]:
        print(meds[0])

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

Solution (Python):
n = int(input())
xx = list(map(int, input().split()))
xs = sorted(xx)
[print( xs[n//2] if x <= xs[n//2-1] else xs[n//2-1] ) for x in xx ]

Solution (Python):
import numpy as np

N=int(raw_input())

X = map(int,raw_input().split())

Y=np.sort(X)

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

for x in X:
	if x<=m1:
		print m2
	else:
		print m1

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
X_sort = sorted(X)
median_large = X_sort[N//2]
median_small = X_sort[N//2-1]
if median_large == median_small:
    for _ in range(N):
        print(median_large)
else:
    for i in range(N):
        if X[i] <= median_small:
            print(median_large)
        elif X[i] >= median_large:
            print(median_small)

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
X_sort = sorted(X)
N_half = int(N/2)
median_large = X_sort[N_half]
median_small = X_sort[N_half-1]
if median_large == median_small:
    for _ in range(N):
        print(median_large)
else:
    for i in range(N):
        if X[i] <= median_small:
            print(median_large)
        elif X[i] >= median_large:
            print(median_small)

Solution (Python):
n=int(input())
x=[int(i) for i in input().split()]
if n==2:
    for i in x[::-1]:
        print(i)
    exit()

d={}
y=sorted(x)



ans={}
for a,i in enumerate(y):
    if a<n//2:
        if i not in ans:
            ans[i]=y[n//2]
    elif a>=n//2:
        if i not in ans:
            ans[i]=y[n//2-1]
            
for i in x:
    print(ans[i])

Solution (Python):
N = int(input())
X = [int(i) for i in input().split()]
x = sorted(X)
n = N // 2
for i in range(N):
    if X[i] < x[n]:
        print(x[n])
    else:
        print(x[n - 1])

Solution (Python):


INF = float('inf')


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


N = int(input())
X = inpl()
Y = sorted(X[:])
median_l = Y[N // 2 - 1]
median_r = Y[N // 2]

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

Solution (Python):
import copy
n = int(input())
list_x = list(map(int, input().split()))
list_a = copy.deepcopy(list_x)
list_a.sort()
mid_up = list_a[n//2]
mid_do = list_a[n//2 - 1]
for i in range(n):
    if list_x[i] < mid_up:
        print(mid_up)
    else:
        print(mid_do)

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

x_sorted = sorted(x)

mL = (n - 1) // 2
mR = mL + 1

anss = []
for i in range(n):
    if x[i] <= x_sorted[mL]:
        anss.append(x_sorted[mR])
    else:
        anss.append(x_sorted[mL])
for ans in anss:
    print(ans)

Solution (Python):
import sys
Input = sys.stdin.readline


N = int(Input())
X = list(map(int, Input().split()))
l = (N-1) // 2

X_idx = [idx for idx, _ in sorted(enumerate(X), key=lambda x: x[1])]
med_r = X[X_idx[N//2]]
med_l = X[X_idx[(N//2)-1]]
for x in X:
    if x < med_r:
        print(med_r)
    else:
        print(med_l)

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

X_sort = sorted([[i,v] for i,v in enumerate(X)], reverse=True, key=lambda x: x[1
])
ans = [0] * N
for i in range(N):
    ans[X_sort[i][0]] = X_sort[(N//2)-(i>=(N//2))][1]
        
for a in ans:
    print(a)

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

X_sort = sorted([[i,v] for i,v in enumerate(X)], reverse=True, key=lambda x: x[1
])
ans = [0] * N
for i in range(N):
    if i<(N//2):
        ans[X_sort[i][0]] = X_sort[N//2][1]
    else:
        ans[X_sort[i][0]] = X_sort[(N//2)-1][1]
        
for a in ans:
    print(a)

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

X_sort = sorted([[i,v] for i,v in enumerate(X)], reverse=True, key=lambda x: x[1
])
ans = [0] * N
ansA = X_sort[(N//2)-1][1]
ansB = X_sort[N//2][1]
for i in range(N):
    if i<(N//2):
        ans[X_sort[i][0]] = ansB
    else:
        ans[X_sort[i][0]] = ansA
        
for a in ans:
    print(a)

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

xx = [(X[i], i) for i in range(N)]
xx.sort()

ans = [0 for i in range(N)]

for i in range(N):
    x, idx = xx[i]
    if i < N // 2:
        ans[idx] = xx[N // 2][0]
    else:
        ans[idx] = xx[N // 2 - 1][0]

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

Solution (Python):
n = int(input())
x = [int(v) for v in input().split()]

x_sorted = sorted(x)
m1 = x_sorted[n//2 - 1]
m2 = x_sorted[n//2]

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

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
xx = sorted(x)
for i in range(n):
    if x[i] >= xx[n // 2]:
        print(xx[n // 2 - 1])
    else:
        print(xx[n // 2])

Solution (Python):
N = int(input())

dic = {}
arr = []
for x in list(map(int,input().split())):
    arr.append(x)
sort_arr = sorted(arr)
mid1 = sort_arr[N//2-1]
mid2 = sort_arr[N//2]

for x in arr:
    if x <= mid1:
        print(mid2)
    else:
        print(mid1)

Solution (Python):
import copy

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

Solution (Python):
import math
n = int(input())
lis = list(map(int,input().split()))
li = sorted(lis)
for i in range(n):
  if lis[i] <= li[int(n/2)-1]:
    print(li[int(n/2)])
  else:
    print(li[int(n/2)-1])

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

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
l=sorted(x)
med=[l[n//2-1],l[n//2]]
for i in x:
    if i<=med[0]:
        print(med[1])
    elif i>=med[1]:
        print(med[0])

Solution (Python):
n=int(input())
x=[int(i) for i in input().split()]
y=[]
for i in x:
    y.append(i)
x.sort()

c=int(n/2)
a=x[c]
b=x[c-1]

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

Solution (Python):


def solver():
    
    from statistics import median_low, median_high

    n = int(input())
    xs = [int(x) for x in input().split()]

    m1, m2 = median_low(xs), median_high(xs)

    medians = (str(m2 if x < m2 else m1) for x in xs)
    print('\n'.join(medians))

def main():
    from statistics import median_low, median_high

    N = int(input())
    Xs = list(map(int, input().split()))
    m_low, m_high = median_low(Xs), median_high(Xs)

    for x in Xs:
        ans = m_high if x <= m_low else m_low
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):


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

Y = sorted(X)

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

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = inp()
xx = inpl()
xx_sort = sorted(xx)
half1 = xx_sort[N//2-1]
half2 = xx_sort[N//2]

for i in range(N):
	if xx[i] <= half1:
		print(half2)
	else:
		print(half1)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
A1 = []
for nums in A:
  A1.append(nums)
A.sort()
m1 = A[N//2-1]
m2 = A[N//2]
if m1 != m2:
  for nums in A1:
    if nums <= m1:
      print(m2)
    else:
      print(m1)

else:
  for nums in A1:
    print(m1)

Solution (Python):
N = int(raw_input())
X = map(int, raw_input().split())
memo = []
for i in range(0, N):
	memo.append(X[i])
memo.sort()
twomed = [memo[N/2-1], memo[N/2]]

for i in range(0, N):
	if X[i] <= twomed[0]: print twomed[1]
	else: print twomed[0]

Solution (Python):
import statistics

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

high = statistics.median_high(x)
low = statistics.median_low(x)

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

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

Y = sorted(X)
L = Y[int(N/2 - 1)]
R = Y[int(N/2)]

for i in range(N):
    if X[i] > L:
        print(L)
    else:
        print(R)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
Xcopy = X[::]
X.sort()
left = X[N//2 - 1]
right = X[N//2]

for i in range(N):
    if Xcopy[i] <= left:
        print(right)
    elif Xcopy[i] >= right:
        print(left)

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

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

Y[int(N/2)]


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

Solution (Python):
N = int(input())
x = list(map(int, input().split()))
x_sorted = sorted(x)
a = x_sorted[(len(x) // 2) - 1]
b = x_sorted[(len(x) // 2)]
for i in x:
  if i <= a:
    print(b)
  else:
    print(a)

Solution (Python):
def main18():
    num = int(input(""));
    buf = input("");
    bufs = buf.split();
    hai = [];
    for i in range(len(bufs)):
        hai.append(int(bufs[i]));
    manhidari = int(num/2);
    manmigi = manhidari + 1;
    kari = hai[:];
    kari.sort();
    hidarin = kari[manhidari-1];
    migin = kari[manmigi-1];

    for i in range(len(hai)):
        if hai[i] >hidarin:
            print(hidarin);
        else:
            print(migin);

if __name__ == '__main__':
    main18()

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
Y = X.copy()
X = sorted(X)
bigger = X[N//2]
smaller = X[N//2-1]

for i in range(N) :
    if Y[i] >= bigger :
        print(smaller)
    else :
        print(bigger)

Solution (Python):
N = int(input())
x_list = [i for i in list(map(int, input().split()))]
tmp = x_list.copy()
x_list.sort()
big = x_list[len(x_list)//2]
small = x_list[len(x_list)//2-1]

for x in tmp:
    if x >= big:
        print(small)
    else:
        print(big)