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):
import numpy as np

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

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

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

Solution (Python):
import numpy as np

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

sort_X = np.sort(X)
l = sort_X[int(N/2 - 1)]
r = sort_X[int(N/2)]

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

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

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

A=X.copy()
A.sort(reverse=True)

left=A[int(N/2)-1]
right=A[int(N/2)]

for i in range(N):
  if X[i]>=left:
    print(right)
  else:
    print(left)

Solution (Python):
N = int(input())
X = [int(i) for i in input().split()]
ans=[]
Y=sorted(X)
a=Y[N//2 -1]
b=Y[N//2]
for x in X:
    if x<= a:
        ans.append(b)
    else:
        ans.append(a)
print('\n'.join(map(str,ans)))

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

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

A = sortX[(N//2)-1]
B = sortX[(N//2)]

for x in X:
    if x<B: print(B)
    else: print(A)

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

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

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

Solution (Python):

import sys
import copy



n = int(sys.stdin.readline().strip())
xArray = list(map(int, sys.stdin.readline().strip().split(" ")))

result = []

sortedArray = sorted(xArray)



for i in range(n):
    midIndex = int(n / 2) -1
    if (sortedArray[midIndex] >= xArray[i]):
        result.append(sortedArray[midIndex + 1])
    else:
        result.append(sortedArray[midIndex])



print('\n'.join(map(str, result)))

Solution (Python):

import sys
import copy



n = int(sys.stdin.readline().strip())
xArray = list(map(int, sys.stdin.readline().strip().split(" ")))

result = []

sortedArray = sorted(xArray)



for i in range(n):
    middle = sortedArray[int((n / 2) - 1)]
    if (middle >= xArray[i]):
        result.append(sortedArray[int(n / 2)])
    else:
        result.append(middle)



print('\n'.join(map(str, result)))

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

Y = sorted(X)

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

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

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


Y=sorted(X)
yu=Y[N]
yd=Y[N-1]
for x in X:
	if x<=yd:
		print(yu)
	else:
		print(yd)

Solution (Python):
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))

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

Solution (Python):
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])

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

Solution (Python):
n = int(input())
A = [int(i) for i in input().split(" ")]
B=A[:]
B.sort()
for i in range(n):
    if A[i]<=B[n//2 - 1]:
        print(B[n//2])
    else:
        print(B[n//2-1])

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

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

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

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

for i in range(N):
  if X[i] < m:
    res = X_sorted[N // 2]
  elif X[i] >= m:
    res = X_sorted[N // 2 - 1]

  print(res)

Solution (Python):
n=int(input());*a,=map(int,input().split());b=sorted(a);l,m=b[n//2-1],b[n//2]
for x in a:print([l,m][x<m])

Solution (Python):
N = int(input())
b = [int(i) for i in input().split()]
c = sorted(b[:])
s = c[(N-1)//2]
l = c[N//2]

for i in b:
    if i > s:
       print(s)
    else:
       print(l)

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

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

x = sorted(X)
ml = x[N//2 - 1]
mr = x[N//2]

for x in X:
    if x <= ml:
        print(mr)
    else:
        print(ml)

Solution (Python):
import numpy as np
n=int(input())
x=list(map(int,input().split(' ')))
x1=x[:]
x.sort()
m1=x[int(n/2)-1]
m2=x[int(n/2)]
for i in range(n):
    now=x1[i]
    if x1[i]<=m1:
        print(m2)
    else:
        print(m1)

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

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

Solution (Python):



n = int(input())


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


xs_sorted = sorted(xs)


l = len(xs_sorted)
l_mid = int(l / 2)


xs_mid_1 = xs_sorted[l_mid - 1]
xs_mid_2 = xs_sorted[l_mid]


for x in xs:
    if x < xs_mid_2:
        print("{}".format(xs_mid_2))
    else:
        print("{}".format(xs_mid_1))

Solution (Python):
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)

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

X.sort()

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

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

X = input().split()
x1 = [int(x) for x in X]
x2 = [int(x) for x in X]

x2.sort()
ml = x2[int((N/2)-1)]
mr = x2[int(N/2)]

for i in range(N):
    if x1[i] <=  ml:
        print("%d"%mr)
    else:
        print("%d"%ml)

Solution (Python):
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])

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

base = int((n + 1) // 2) - 1
median = sorted_l[base]
for i in l:
    if i <= median:
        print(sorted_l[base + 1])
    else:
        print(sorted_l[base])

Solution (Python):
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])

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
sorted_x = list(sorted(x))
l, r = sorted_x[len(x) // 2 - 1], sorted_x[len(x) // 2]

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()
    s = sorted(a)
    r = []
    if n % 2 == 0:
        b = s[n//2-1]
        c = s[n//2]
        for t in a:
            if t <= b:
                r.append(c)
            else:
                r.append(b)
    else:
        b = s[n//2]
        c = s[n//2-1]
        for t in a:
            if t >= b:
                r.append(c)
            else:
                r.append(b)


    return '\n'.join(map(str,r))


print(main())

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
a = sorted(range(n), key=lambda i: x[i])
l = x[a[n//2-1]]
r = x[a[n//2]]
b = [0]*n
for i, j in enumerate(a):
    if i < n//2:
        b[j] = r
    else:
        b[j] = l
for e in b:
    print(e)

Solution (Python):
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])

Solution (Python):

"""
Contents   : AtCoder Regular Contest 095 c問題
Author     : Kitaura Hiromi
LastUpdate : 20180414
Since      : 20180414
"""
import random
import copy

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

Solution (Python):
n = int(input())
p = list(map(int,input().split()))
q = sorted(p)
med_1 = q[n//2-1]
med_2 = q[n//2]

for i in range(n):
    if p[i] == med_1:
        print(med_2)
    elif p[i] == med_2:
        print(med_1)
    elif p[i] < med_1:
        print(med_2)
    else:
        print(med_1)

Solution (Python):
import numpy as np
N = int(raw_input())
line = np.array(map(int,raw_input().split()))

line2 = np.sort(line)
t = (float(line2[N / 2 -1]) + float(line2[N / 2])) / 2

for i in range(N):
    if line[i] < t:
        print line2[N / 2]
    else:
        print line2[N / 2 - 1]

Solution (Python):



n = int(input())
X = [int(x) for x in input().split()]
X_sorted = sorted(X)

med_l = X_sorted[n // 2 - 1]
med_u = X_sorted[n // 2]
med = (med_l + med_u) / 2

for x in X:
    if x < med:
        print(med_u)
    else:
        print(med_l)

Solution (Python):
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]))))

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

N = int(input())
ns = inpl()
nss = sorted(ns)
c1 = nss[int(N/2)-1]
c2 = nss[int(N/2)]
for i in range(N):
	if ns[i] <= c1:
		print(c2)
	else:
		print(c1)

Solution (Python):
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)



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)

Solution (Python):
f = lambda :[int(i) for i in input().split()]
from sys import stderr
from functools import reduce
from operator import add
debug = lambda *x:stderr.write(reduce(add,repr(x))+'\n')

n = int(input())
x = f()
y = sorted(x)
med = (y[int(n/2)]+y[int(n/2)-1])/2
lmed = y[int(n/2)]
smed = y[int(n/2)-1]

for po in x:
    if po < med:
        print(lmed)
    else:
        print(smed)

Solution (Python):
import random


def mid_1(X):
    return X[(len(X)) // 2]


def mid(X):
    return X[(len(X)) // 2 - 1]


def main():
    N = int(input())

    X = list(map(int, input().split()))
    
    
    X_ = X[:]
    X_.sort()
    X__ = X_[:N // 2]
    X__ = X__[-1]

    x_1 = mid_1(X_)
    x = mid(X_)

    ans = []
    
    
    for i in range(N):
        if X[i] <= X__:
            print(x_1)
            
        else:
            print(x)
            


if __name__ == '__main__':
    main()

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

sortedX = sorted(X)
medSmall = sortedX[N/2-1]
medLarge = sortedX[N/2]



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

Solution (Python):
import sys
from collections import Counter
import random
import numpy as np

n=int(input())
x=np.array(list(map(int,input().split())))
z=sorted(x)
cand=[z[n//2-1],z[n//2]]

dic={}
for i in range(n):
    a=x[i]
    if(a<=cand[0]):print(cand[1])
    else:print(cand[0])

Solution (Python):
import numpy as np
N = int(input())
X = list(map(int, input().split()))

sx = np.sort(X)
for i in range(N):
    if X[i] >= sx[N//2]:
        print(sx[N//2-1])
    else:
        print(sx[N//2])

Solution (Python):


n = int(input())
xx = list([i, x] for i, x in enumerate(map(int, input().split())))
xx.sort(key=lambda x: x[1])

mid1 = xx[n // 2][1]
mid2 = xx[n // 2 - 1][1]
for i in range(n // 2):
    xx[i][1] = mid1
for i in range(n // 2, n):
    xx[i][1] = mid2

xx.sort()
print('\n'.join(str(x[1]) for x in xx))

Solution (Python):

n = int(input())
x = list(map(int, input().split()))
x_sort = x.copy()
x_sort.sort()
row = x_sort[n//2 - 1]
high = x_sort[n//2]

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

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

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

Solution (Python):


import numpy as np
import copy

n = int(raw_input())
x = map(int,raw_input().split())

x_min = copy.copy(x)
x_max = copy.copy(x)

x_min.remove(max(x))
x_max.remove(min(x))

med_x_min = int(np.median(x_min))
med_x_max = int(np.median(x_max))

if med_x_max == med_x_min:
    for i in range(n):
        print med_x_max
else:
    for i in range(n):
        if x[i] >= med_x_max:
            print med_x_min
        else:
            print med_x_max

Solution (Python):

import numpy as np
N = int(input())
X = np.array(list(map(int, input().split())))
idx = X.argsort()
low = idx[N//2-1]
high = idx[N//2]

res = np.zeros(N, dtype=int)
res[idx[:N//2]] = X[high]
res[idx[N//2:]] = X[low]

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

Solution (Python):
import numpy as np

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

rank = np.argsort(X)
irank = {k: v for v, k in enumerate(rank)}

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

Solution (Python):
input()
xs = list(map(int, input().split()))
sortx = sorted(xs)
l = len(xs)
t = (l+1)//2 - 1
medv = sortx[t]
if l%2 == 0:
    v1 = medv
    v2 = sortx[t+1]
    for x in xs:
        if x <= medv:
            print(v2)
        else:
            print(v1)
else:
    v1 = sortx[t-1]
    v2 = medv
    for x in xs:
        if x < medv:
            print(v2)
        else:
            print(v1)

Solution (Python):
n = int(input())
x = []
x = list(map(int,input().split(' ')))
y = []
for i in range(len(x)):
    y.append(x[i])

y.sort()




b = int(n/2)
s = int(n/2)-1

if n == 2:
    print(x[1])
    print(x[0])
else:
    for i in range(n):
        if x[i] >= y[b]:
            print(y[s])
        else:
            print(y[b])

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
Y = X.copy()
Y.sort()
if N % 2 == 1:
    Bmin = Y[N // 2 - 1]
    Bmid = Y[N // 2]
    Bmax = Y[N // 2 + 1]
    for i in X:
        if i < Bmid:
            print((Bmid + Bmax) / 2)
        elif i > Bmid:
            print((Bmid + Bmin) / 2)
        else:
            print(Bmid)
else:
    Bmin = Y[N // 2 - 1]
    Bmax = Y[N // 2]
    for i in X:
        if i <= Bmin:
            print(Bmax)
        elif i >= Bmax:
            print(Bmin)

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

Solution (Python):
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)

Solution (Python):


import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq





def solve(f):
    n = f.read_int()
    x = f.read_int_list()
    x0 = x[:]

    x.sort()
    med = x[n/2-1]
    ans = []
    for xi in x0:
        if xi > med:
            ans.append(med)
        else:
            ans.append(x[n/2])

    return "\n".join(map(str, ans))


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case 
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

Solution (Python):


count = int(input())
li = list(map(int, input().split()))

sli = sorted(li)

default_median_index = int((len(sli) + 1) / 2)
default_median = sli[default_median_index]

for i in range(len(li)):
    r = li[i]
    if r < default_median:
        print(default_median)
    else:
        print(sli[default_median_index - 1])

Solution (Python):
n = int(input())
p = list(map(int,input().split()))
q = sorted(p)
if n != 2:
    med_1 = q[n//2-1]
    med_2 = q[n//2]
    
    for i in range(n):
        if p[i] == med_1:
            print(med_2)
        elif p[i] == med_2:
            print(med_1)
        elif p[i] < med_1:
            print(med_2)
        else:
            print(med_1)
else:
    print(p[1])
    print(p[0])

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

M1, M2 = sorted(Xs)[N // 2 - 1: N // 2 + 1]

for X in Xs:
    if X < M2:
        print(M2)
    else:
        print(M1)

Solution (Python):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
x=i2()
z=[]
for i in range(n):
 z.append([x[i],i])
y=sorted(z)
s1=y[n//2-1]
s2=y[n//2]
yy=[0 for i in range(n)]
for i in range(n):
 if i<=n//2-1:
   yy[y[i][1]]=s2
 else:
   yy[y[i][1]]=s1
for i in yy:
 print(i[0])

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

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

a_s=sorted(a)

bf=a_s[n//2-1]
bl=a_s[n//2]

for ele in a:
    if(ele>=bl):
        print(bf)
    else:
        print(bl)

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

y = list(sorted(x))
for xi in x:
    if xi <= y[n // 2 - 1]:
        print(y[n // 2])
    else:
        print(y[n // 2 - 1])

Solution (Python):
N = int(input())
X = [int(i) for i in input().split()]
a = X.copy()
a.sort()
a_l = a[N // 2 - 1]
a_r = a[N // 2]
for i in range(N):
    if X[i] <= a_l:
        print(a_r)
    else:
        print(a_l)

Solution (Python):
def solve(n, nums):
    sorted_nums = sorted(nums)
    low = sorted_nums[n/2 - 1]
    high = sorted_nums[n/2]

    for i in xrange(n):
        if nums[i] <= low:
            print high
        else:
            print low
    return


n = int(raw_input())
nums = map(int, raw_input().split())
solve(n, nums)

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

Solution (Python):

def inpl(): return list(map(int, input().split()))
N = int(input())
X = inpl()
Y = [[x, i] for i, x in enumerate(X)]
Y = sorted(Y)
if (N-1)%2==1:
    l = Y[(N-1)//2][0]
    r = Y[(N-1)//2+1][0]
    for i in range(N):
        if X[i]<=l:
            print(r)
        else:
            print(l)

Solution (Python):



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

a=sorted(A)

d=a[N//2]
c=a[N//2 -1]

for i in A:
    if i >= d:
        print(str(c))
    else:
        print(str(d))

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

Solution (Python):
N = int(input())
M = N//2
x = list(map(int, input().split()))
y = sorted(x)

thre = y[M]

ans_b = y[M]
ans_s = y[M-1]

for x_ in x:
    if x_ >= thre:
        print(ans_s)
    else:
        print(ans_b)

Solution (Python):
N = int(input())
inline = list(map(int,input().split()))
so = inline.copy()
so.sort()


left = so[int(N/2)-1]
right = so[int(N/2)]


for i in range(N):
    if inline[i] <= left:
        print(right)
    else:
        print(left)

Solution (Python):
'''
def binsearch(x, t):
    low = 0
    high = len(x) - 1
    k = (low + high) // 2
    if x[low] == t:
        return low
    if x[high] == t:
        return high
    while (low <= high):
        if x[k] < t:
            low = k
        elif x[k] > t:
            high = k
        else:
            return k
        k = (low + high) // 2
'''
N=int(input())
X=[int(i) for i in input().split()]
Y=sorted(X)
M=N//2
L=Y[M-1]
R=Y[M]
for i in range(N):
    if X[i]<=L:
        print(R)
    else:
        print(L)

Solution (Python):
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])

Solution (Python):
N = int(input())
src = list(map(int,input().split()))
ss = sorted(src)
m1 = ss[N//2 - 1]
m2 = ss[N//2]

for a in src:
    if a <= m1:
        print(m2)
    else:
        print(m1)

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

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

Ys = Xs[:]
Ys.sort()

a = Ys[N//2 - 1]
b = Ys[N//2]

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

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

xs = sorted(X)

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

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

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

Solution (Python):
N = int(input())
X = list(map(int,input().split(" ")))
X2 = X[:]
X2.sort()
mid = (N-1)//2
l = X2[mid]
r = X2[mid+1]
for i in range(N):
	if X[i] <= l:
		print(r)
	else:
		print(l)

Solution (Python):
n = int(input())
*x, = map(int, input().split())
y = sorted(x)
p, q = y[n//2-1:n//2+1]
ans = []
for i in range(n):
    if x[i] < q:
        ans.append(q)
    else:
        ans.append(p)
print(*ans, sep='\n')

Solution (Python):

N = int(input())
X_list = list(map(int, input().split()))
X_list_s = sorted(X_list)
Right = X_list_s[N // 2]
Left = X_list_s[(N // 2) - 1]
for i in range(N):
    if X_list[i] >= Right:
        print(Left)
    else:
        print(Right)

Solution (Python):
N = int(input())
arr = list(map(int, input().split()))
arr2 = sorted(arr)

mean1 = arr2[N//2-1]
mean2 = arr2[N//2]

for a in arr:
  if a <= mean1:
    print(mean2)
  else:
    print(mean1)

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

S = sorted(A)
x,y = S[len(A)//2-1], S[len(A)//2]

for a in A:
  if a <= x:
    print(y)
  else:
    print(x)

Solution (Python):
if __name__ == '__main__':

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

    xs_sorted = sorted(xs)
    cand_s, cand_l = xs_sorted[n // 2 - 1], xs_sorted[n // 2]

    for x in xs:
        print(cand_l if x <= cand_s else cand_s)

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

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

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