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())
List=list(map(int,input().split()))
AList=List[:]
List.sort()
div=List[N//2]
backdiv=List[N//2-1]
for indexnum in AList:
    if div > indexnum:
        print(div)
    else:
        print(backdiv)

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

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

for i in x:
  if i <= l[n//2-1]:
    print(l[n//2])
  else:
    print(l[n//2-1])

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

le = len(x)
m_idx = le // 2 - 1
m0 = (x_s[m_idx]+x_s[m_idx+1]) / 2

for i in range(len(x)):
    if x[i] == m0:
        print(x[i])

    elif x[i] < m0:
        print(x_s[m_idx+1])

    elif x[i] > m0:
        print(x_s[m_idx])

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

sX = sorted(X)
d = N // 2
a = sX[d]
b = sX[d - 1]

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

Solution (Python):
n=int(input())
x=list(map(int, input().split()))
xs=sorted(x)
n1=int(n/2)-1
n2=n1+1

for xi in x:
    if xi<=xs[n1]:
        print(xs[n2])
    else:
        print(xs[n1])

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

Xsort = sorted(X)
lmedian = Xsort[int(N/2) - 1]
rmedian = Xsort[int(N/2)]

for x in X:
	print (rmedian if x <= lmedian else lmedian)

Solution (Python):
import copy

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

x_original_order = copy.deepcopy(x)

x.sort()
large = x[int(n/2)]
small = x[int(n/2)-1]

for i in x_original_order:
	if i <= small:
		print(large)
	else:
		print(small)

Solution (Python):



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


X_sorted = sorted(X)
n0 = X_sorted[int(len(X_sorted)/2-1)]
n1 = X_sorted[int(len(X_sorted)/2)]
for i in range(len(X)):
    if (n1 > X[i]):
        print(n1)
    elif (n0 <= X[i]):
        print(n0)

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

a=Y[int((N-1)/2)]
b=Y[int((N+1)/2)]

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

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

Solution (Python):
N=input()
X=map(int, raw_input().split())
S=[]
for idx,i in enumerate(X):
	S.append( (i,idx) )

a=sorted(S, key=lambda x: x[0], reverse=True)


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

	val=a[i][0]
	pntr=a[i][1]

	l=i-0
	if (N+1)/2-l>0:
		diff=(N+1)/2-l
	else:
		diff=(N+1)/2-l-1

	ans[pntr]=a[i+diff][0]

for i in ans:
	print i

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

tmp = n//2

tmp_array = sort_array[tmp-1:tmp+1]

for i in array:
    if i <= tmp_array[0]:
        print(tmp_array[1])
    else:
        print(tmp_array[0])

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

X_sort = sorted(X)
t = X_sort[len(X)//2]

for i in X:
    if i < t:
        print(X_sort[len(X)//2])
    else: print(X_sort[len(X)//2-1])

Solution (Python):

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


x_copy = sorted(x, reverse=False)
half = int(n/2)
half_minus = x_copy[half-1]
half_plus = x_copy[half]





for xi in x:
    if xi <= half_minus:
        print(half_plus)
    else:
        print(half_minus)

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

a = len(x)
b = sorted(x)
fa = b[int((a/2)-1)]
se = b[int(a/2)]

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

Solution (Python):
N = int(input())
array = list(map(int, input().split()))
test = list(array)
test.sort()
wow = test[int(N / 2) - 1: int(N / 2) + 1]
for i in range(0, N):
    if array[i] > wow[0]:
        print(wow[0])
    else:
        print(wow[1])

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

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

y = sorted(x, reverse=True)
mid = int(n / 2) - 1

for i in x:
    if(i >= y[mid]):
        if(mid + 1 != n):
            print(y[mid+1])
        else:
            print(y[mid])
    else:
        print(y[mid])

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

Solution (Python):


import copy

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

    t = copy.deepcopy(x)
    t.remove(min(x))
    t.sort()
    m1 = t[int(n / 2 - 1)]
    t = copy.deepcopy(x)
    t.remove(max(x))
    t.sort()
    m2 = t[int(n / 2 - 1)]
    for i in range(n):
        print(m1 if x[i] < m1 else m2)

if __name__ == '__main__':
    main()

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

Solution (Python):
from statistics import median


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

for x in X:
    if x < medi_X:
        print(sort_X[int((N + 1) / 2)])
    else:
        print(sort_X[int(((N + 1) / 2) - 1)])

Solution (Python):
N = int(input())
n = int(N/2)

li = list(map(int,input().split()))
li_s = sorted(li)

A = li_s[n-1]
B = li_s[n]

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

Solution (Python):
import bisect


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    N = get_next_int()
    X = get_next_ints()

    x_sorted = sorted(X)
    med_index = int((N-1)/2)
    
    for num in X:
        index = bisect.bisect(x_sorted, num)-1
        if index > med_index:
            print(x_sorted[med_index])
        else:
            print(x_sorted[med_index+1])



solve()

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

Solution (Python):
def medians(nums):
    n = len(nums)
    num_orig_pos = list(zip(nums, range(n)))
    nums_sorted = sorted(num_orig_pos)
    medians = []
    med_left = nums_sorted[(n + 1)//2][0]
    med_right = nums_sorted[(n + 1)//2 - 1][0]
    for i in range((n + 1)//2):
        medians.append((med_left, nums_sorted[i][1]))
    for i in range((n + 1)//2, n):
        medians.append((med_right, nums_sorted[i][1]))
    return map(lambda x: x[0], sorted(medians, key=lambda x: x[1]))


if __name__ == '__main__':
    _ = input()
    nums = list(map(int, input().split()))
    for i in medians(nums):
        print(i)

Solution (Python):
import copy

n = int(input())
x = list(map(int,input().split()))
lst = copy.deepcopy(x)
lst.sort()
med_l = lst[n//2-1]
med_r = lst[n//2]

for i in range(len(x)):
    if x[i]<=med_l: print(med_r)
    else: print(med_l)

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

b=sorted(x)[int(n/2)]
s=sorted(x)[int(n/2-1)]

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

Solution (Python):
if __name__ == '__main__':
	n = int(input())
	x = [int(x) for x in input().split(' ')]

	sx = sorted(x)
	med = sx[int(n/2)]
	medl = sx[int(n/2-1)]

	for i in range(n):
		if x[i] < med:
			print(med)
		else:
			print(medl)

Solution (Python):
size =  int(input().strip())
nums  = list(map(int, input().strip().split(' ')))
sortedNums = sorted(nums)
x1 = sortedNums[int(size/2-1)]
x2 = sortedNums[int(size/2)]
for i in nums:
    if(x1 == x2):
        print(x1)
    elif (i>=x2):
        print(x1)
    else:
        print(x2)

Solution (Python):
def abc094C():
    n = int(input())
    x = input().split()
    x = list(map(int, x))
    y = x.copy()
    y.sort()
    nums = y[int(n / 2 - 1): int(n / 2 + 1)]
    for i in range(n):
        tf = nums[0] >= x[i]
        print(nums[tf])


abc094C()

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

X_sort = sorted(X)
small, big = X_sort[N//2-1], X_sort[N//2]

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

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

li = list(map(int,input().split()))
copiedListForSort = li.copy()
copiedListForSort.sort()

firstMedian = copiedListForSort[N//2 - 1]
secondMedian = copiedListForSort[N//2]
for i in range(N):
    if li[i] >= secondMedian:
        print(firstMedian)
    else:
        print(secondMedian)

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

X_sort = sorted(X)
small, big = X_sort[N//2-1], X_sort[N//2]

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

Solution (Python):
import copy

N = int(input())
num = list(map(int,input().split()))
memo = copy.deepcopy(num)
num.sort()

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

Solution (Python):
N = int(input())
X = tuple(int(x) for x in input().split())
length = len(X)
med = sorted(X)[length//2-1:length//2+1]
for x in X:
 print(med[1] if x < sum(med)/2 else med[0])

Solution (Python):
N = int(input())
numList = list(map(int, input().split()))
sortedList = sorted(numList)
center = N // 2
left_median = sortedList[center - 1]
right_median = sortedList[center]

answer = [str(left_median) if i >= right_median else str(right_median) for i in numList]
print("\n".join(answer))

Solution (Python):



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

X_list2 = X_list[:]
X_list2.sort()
smaller = X_list2[N//2 -1]
larger = X_list2[N//2]

for element in X_list:
    if element <= smaller:
        print(larger)
    else:
        print(smaller)

Solution (Python):
N = int(input())
INPUT = input()
X_list = list(map(int, INPUT.split()))
X_sorted = sorted(X_list)
criterion = X_sorted[int(N / 2 - 1)]

for i in range(N):
    if X_list[i] > criterion:
        print(criterion)
    else:
        print(X_sorted[int(N / 2)])

Solution (Python):
import copy

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

Solution (Python):
import math
n = int(input())
lis = list(map(int,input().split()))
li = sorted(lis)
ans2 = li[math.ceil((n-1)/2)]
cou2 = lis.count(ans2)
ans1 = li[math.floor((n-1)/2)]
cou1 = lis.count(ans1)
for i in range(n):
	if lis[i] >= ans2:
		print(ans1)
	else:
		print(ans2)

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

mid_left = sortx[(n//2)-1]
mid_right = sortx[(n//2)]

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

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

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

Solution (Python):
def main():
    N = int(input())
    X = tuple(map(int, input().split()))

    x2 = sorted(X)
    mid1 = x2[N//2 - 1]
    mid2 = x2[N//2]
    for i in X:
        if i < mid2:
            print(mid2)
        else:
            print(mid1)

main()

Solution (Python):
import sys
if __name__ == "__main__":
    N = int(input())
    X = list(map(int, (input().split(' '))))
    buf = sorted(X)
    for i in range(N):





        if X[i] < buf[int(N/2)]:
            print(buf[int(N/2)])
        else:
            print(buf[int(N/2)-1])

Solution (Python):
n= int(input())
m = int(n//2)
data = [int(i) for i in input().split()]

sdata = sorted(data)


for i in range(n):
    if data[i] < sdata[m]:
        print(sdata[m])
    else:
        print(sdata[m-1])

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

sort=sorted(X)

a=int(N/2-1)
b=int(N/2)

A=sort[a]
B=sort[b]

for i in range(N):
    if X[i]<=A:
        print(B)
    elif X[i]>=B:
        print(A)

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

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

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
Y = X[:]
Y.sort()
p = int(N/2)

if Y[p-1] == Y[p]:
    flag = 1
else:
    flag = 0



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

Solution (Python):

N = int(input())
X = [0]*N
X = list(map(int, input().split()))
Y = X[:]
hoge = 0

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

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
s = sorted(X)
midu = s[int(N/2)]
midd = s[int(N/2 - 1)]

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

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

xs_arranged = sorted(xs)
l = int(n/2 - 1)
a1,a2 = xs_arranged[l],xs_arranged[l+1]
base = (a1+a2)/2
    
for i in xs:
    if i < base:
        print(a2)
    else:
        print(a1)

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

Solution (Python):
import numpy as np

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

M = np.median(X)

Y = sorted(X)
a = Y[int(len(Y)/2 - 1)]
b = Y[int(len(Y)/2)]

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

Solution (Python):
n = int(input())
x = list(map(int,input().split()))
import numpy as np
import copy
md = np.median(x)
x_c = copy.copy(x)
x_c.sort()
a = x_c[int(n/2 - 1)]
b = x_c[int(n/2)]
for i in range(n):
    if x[i] < md:
        print(b)
    else:
        print(a)

Solution (Python):
import sys
import numpy as np

N = int(sys.stdin.readline().strip())
s = int(N / 2)
x = np.array(list(map(lambda x: int(x), sys.stdin.readline().strip().split(" "))))
index_list = np.argsort(x)

array_x = sorted(x)

a = array_x[s]

for i in range(N):
    if x[i] < a:
        print(array_x[s])
    else:
        print(array_x[s-1])

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

x_sorted = sorted(x)
length = len(x) - 1
center_min = x_sorted[(length - 1) // 2]
center_max = x_sorted[(length + 1) // 2]
for elem in x:
    if elem <= center_min:
        print(center_max)
    else:
        print(center_min)

Solution (Python):
n = int(input())
x=[int(i) for i in input().split()]
sorted_x = sorted(x)
min = sorted_x[int((n/2)-1)]
max = sorted_x[int(n/2)] 

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

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

Solution (Python):


n = int(input())

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

sorted_x = sorted(x)

before_half = sorted_x[n//2 - 1]
after_half = sorted_x[n//2]

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

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

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

xx = sorted(X)
a = xx[N//2-1]
b = xx[N//2]

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

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
x = na()
xx = sorted(x, reverse=True)
mid = n // 2 - 1
ans = xx[mid]
for i in range(n):
    if x[i] >= ans:
        print(xx[mid+1])
    else:
        print(ans)

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

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

Xs = sorted(X)
median1 = Xs[int(N/2)-1]
median2 = Xs[int(N/2)]

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

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

m_large = x_sorted[n // 2]
m_small = x_sorted[n // 2 - 1]

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

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
sx = sorted(x)
a = sx[n//2 -1]
b = sx[n//2]
for i in x:
    if i > a:
        print(a)
    else:
        print(b)

Solution (Python):
import statistics

n=int(input())
li= list(map(int,input().split()))
lmedi=statistics.median_low(li)
hmedi=statistics.median_high(li)
for xn in li:
    if xn<=lmedi:
        print(hmedi)
    else:
        print(lmedi)

Solution (Python):



N = int(input())
Xs = list(map(int, input().split(' ')))
sortX = sorted(Xs)
B1 = sortX[int(N / 2 - 1)]
B2 = sortX[int(N / 2)]


for X in Xs:
    if X <= B1:
        print(B2)
    else:
        print(B1)

Solution (Python):
import sys
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = []
    for i in range(N):
        A.append(int(input_raw[i]))
    sorted_A = sorted(A)

    l_left = N/2
    l_right = N/2 + 1
    for i in range(1, N + 1):
        if A[i - 1] <= sorted_A[l_left - 1]:
            print sorted_A[l_right - 1]
        else:
            print sorted_A[l_left - 1]


if __name__ == '__main__':
    main()

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

Solution (Python):
from bisect import *
from operator import *
from statistics import *

n = int(input())
x = list(map(int, input().split()))
med_low = median_low(x)
med_high = median_high(x)
x_sorted = sorted(x)

for i in range(n):
    if bisect_left(x_sorted, x[i]) < n/2:
        print(med_high)
    else:
        print(med_low)

Solution (Python):
n = input()
x = map(int, raw_input().split())
x2 = sorted(x)
mid1 = x2[(n/2)-1]
mid2 = x2[n/2]
if mid1 == mid2:
    for i in xrange(n):
        print mid1
else:
    for i in xrange(n):
        if x[i] <= mid1:
            print mid2
        else:
            print mid1

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

Ami=Ans[N//2-1]
Ama=Ans[N//2]

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

Solution (Python):
from statistics import mean, median,variance,stdev
n=int(input())
nn=n//2
x=[int(i) for i in input().split()]
y=x[:]
x.sort()

low_median=median(x[:n-1])
high_median=median(x[1:])

for i in range(n):
  if y[i]<high_median:
    print(high_median)
  else:
    print(low_median)

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
XS = sorted(X)
h = N//2
l,r = XS[h-1],XS[h]
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_s = sorted(X)

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

for xi in X:
    if xi < m2:
        print(m2)
    else:
        print(m1)

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    X = list(map(int, input().split()))
    X_sorted = sorted(X)

    median_candidates = X_sorted[(N // 2 - 1)], X_sorted[N // 2]
    for X_i in X:
        if X_i < median_candidates[1]:
            print(median_candidates[1])
        else:
            print(median_candidates[0])

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

A = x.copy()
A.sort()
a1 = A[int(len(x)/2)]
a2 = A[int(len(x)/2)-1]
for i in range(n):
    if x[i] < a1:
        print(a1)
    else:
        print(a2)

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    X = list(map(int, input().split()))
    X_sorted = sorted(X)

    cand1 = X_sorted[N // 2 - 1]
    cand2 = X_sorted[N // 2]

    for target in X:
        if cand1 >= target:
            print(cand2)
        else:
            print(cand1)

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

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

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

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

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

mid = sorted(X_LIST)[int(N / 2) - 1]
next_mid = sorted(X_LIST)[int(N / 2)]

for x in X_LIST:
    if x <= mid:
        print(next_mid)
    else:
        print(mid)

Solution (Python):


import numpy as np

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

Xed = sorted(X)

t1 = Xed[int(N/2)-1]
t2 = Xed[int(N/2)]

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

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

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

sx = sorted(X)
a = sx[N // 2 - 1]
b = sx[N // 2]

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

Solution (Python):
n=int(input())
lst1=list(map(int,input().split()))
lst2=sorted(lst1)
left=lst2[int(n/2)-1]
right=lst2[int(n/2)]
for num in lst1:
    if num<=left:
        print(right)
    else:
        print(left)

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


sX = sorted(X)
a, b = sX[N//2-1], sX[N//2]
for i in X:
    if i==a and i==b:
        print(a)
    elif i<=a:
        print(b)
    else:
        print(a)

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

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

Y = sorted(X)
right_center = Y[N // 2]
left_center = Y[N // 2 - 1]
for i in X:
    if i < right_center:
        print(right_center)
    elif i > left_center:
        print(left_center)
    
    elif i == right_center:
        print(right_center)

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

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

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

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

Y = X[:]
Y.sort()
a = Y[N//2-1]
b = Y[N//2]

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

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

Solution (Python):
N = int(input())
L = list(map(int, input().split()))
l = len(L)
L2 = sorted(L)
ans = (L2[l//2 - 1], L2[l//2])

if ans[0] == ans[1]:
    for n in range(N):
        print(ans[0])
else:
    for n in L:
        if n < ans[1]:
            print(ans[1])
        else:
            print(ans[0])

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

x_sort = sorted(x)
l_mid = x_sort[int(n/2)-1]
r_mid = x_sort[int(n/2)]

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

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

Solution (Python):
n = int(raw_input())
x = map(int,raw_input().split())
x2 = sorted(x)

m1 = x2[n/2 - 1]
m2 = x2[n/2]

if m1 == m2:
  for a in range(n):
    print m1
  exit(0)

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

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

Solution (Python):
N = int(input())
xs = list(map(int,input().split()))
sortxs = [i for i in xs]
sortxs.sort()
mins = sortxs[N//2-1]
majs = sortxs[N//2]
for i in range(N):
    t = xs[i]
    if t <= mins:
        print(majs)
    else:
        print(mins)

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

Xsort = sorted(X)
medR = Xsort[N//2]
medL = Xsort[N//2-1]

for i in X:
    if i < medR:
        print(medR)
    else:
        print(medL)

Solution (Python):
n=int(raw_input())
a=[int(k) for k in raw_input().split(" ")]

sa=sorted(a)
mn,mx=sa[n/2-1],sa[n/2]

for k in a:
    if k<=mn:
        print mx
    else:
        print mn

Solution (Python):
n=int(input())
x=[int(a) for a in input().split()]
sx = sorted(x)
a=sx[n//2-1]
b=sx[n//2]
for c in x:
    if c <=a:
        print(b)
    else:
        print(a)

Solution (Python):
input()
x=[int(x) for x in input().split()]
y=sorted(x)
l=y[len(x)//2-1]
r=y[len(x)//2]
for xi in x:
  if xi < r:
    print(r)
  else:
    print(l)