CodeEff/ECCO huggingface dataset:
# Original solution
def abc094C():
    n = int(eval(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):
        y = x.copy()
        tf = nums[0] >= y[i]
        del y[i]
        y.sort()
        print((nums[tf]))


abc094C()

# Optimized solution
def abc094C():
    n = int(eval(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()
# Original solution
import statistics
N = int(eval(input()))
L = list(map(int,input().split()))
for i in range(N):
    Li = L[0:i] + L [i+1::]
    k = statistics.median(Li)
    print(k)

# Optimized solution
n = int(eval(input()))
a = list(map(int,input().split()))
b = tuple(a)
a.sort()
A1 = a[n//2-1]
A2 = a[n//2]
med = (A1+A2)/2
for i in range(n):
    if b[i] <= med:
        print(A2)
    else:
        print(A1)
# Original solution
import statistics
import copy

n = int(eval(input()))
a = list(map(int, input().split()))
ao = copy.copy(a)
for i in range(n):
    a.pop(i)
    print((statistics.median(a)))
    a = copy.copy(ao)


# Optimized solution
import statistics

n = int(eval(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]))
# Original solution
n=int(eval(input()))
x=list(map(int,input().split()))
import statistics
for i in range(n):
    y=x[i]
    x.pop(i)
    print((statistics.median(x)))
    x.insert(i,y)

# Optimized solution
n = int(eval(input()))
x = list(map(int, input().split()))

lst = sorted(x)
small_med = lst[n // 2 - 1]
big_med = lst[n // 2]

for num in x:
    if num > small_med:
        print(small_med)
    else:
        print(big_med)
# Original solution
N = int(eval(input()))
X = list(map(int, input().split()))

tmp = [0] * N
for i in range(N):
    tmp[i] = X[i]

tmp.sort()
mid_left = tmp[N // 2 - 1]
mid_right = tmp[N // 2]



for i in X:
    if i <= mid_left:
        print(mid_right)
    else:
        print(mid_left)


# Optimized solution
N = int(eval(input()))
X = list(map(int, input().split()))

sort_x = sorted(X, key= lambda x: x)

mid_left = sort_x[N // 2 - 1]
mid_right = sort_x[N // 2]

for i in X:
    if i <= mid_left:
        print(mid_right)
    else:
        print(mid_left)
# Original solution
n = int(eval(input()))
*l, = list(map(int, input().split()))

for i in range(n):
    _l = l[:]
    _l.pop(i)
    _l.sort()
    print((_l[(n-1)//2]))


# Optimized solution
n = int(eval(input()))
*l, = list(map(int, input().split()))

p, q = sorted(l)[n//2-1 : n//2+1]
for _l in l:
    print((p if _l >= q else q))
# Original solution
N=int(eval(input()))
X=list(map(int,input().split()))

X_sort=sorted(X)

if X_sort[N//2-1]==X_sort[N//2]:
    for n in range(N):
        print((X_sort[N//2]))
else:
    if X_sort.count(X_sort[N//2-1])==1:
        for n in range(N):
            if X[n]>X_sort[N//2-1]:
                print((X_sort[N//2-1]))
            else:
                print((X_sort[N//2]))
    else:
        for n in range(N):
            if X[n]>X_sort[N//2-1]:
                print((X_sort[N//2-1]))
            else:
                print((X_sort[N//2]))


# Optimized solution
N = int(eval(input()))
X = list(map(int,input().split()))
Xs = sorted(X)
Bl = Xs[(N-1)//2]
Br = Xs[N//2]
for i in range(N):
    if Bl < X[i]:
        print(Bl)
    else:
        print(Br)
# Original solution
n = int(eval(input()))
X = list(map(int, input().split()))
X_sort = sorted(X)
mi = (n-1)//2
for i in range(n):
    X_ = X_sort.copy()
    X_.remove(X[i])
    print((X_[mi]))

# Optimized solution
n = int(eval(input()))
X = list(map(int, input().split()))
X_sort = sorted(X)
xm1 = X_sort[n//2-1]
xm2 = X_sort[n//2]
xm = (xm1+xm2)/2
for i in range(n):
    if X[i]<xm:
        print(xm2)
    else:
        print(xm1)
# Original solution
N = int(eval(input()))
X = tuple(map(int,input().split()))
test = int(N/2)
for i in range(len(X)):
    temp = list(X)
    temp.pop(i)
    temp = sorted(temp)
    print((temp[test-1]))


# Optimized solution
N = int(eval(input()))
X = list(map(int,input().split()))
X_sorted = sorted(X)
X_median = (N)/2
median1 = X_sorted[int(X_median)]
median2 = X_sorted[int(X_median-1)]
for i in range(N):
    if X[i] >=median1:
        print(median2)
    else:
        print(median1)
# Original solution
N,*X = list(map(int,open(0).read().split()))
chu = N//2
for i in range(N):
    copy_X = X[:]
    copy_X.sort()
    copy_X.reverse()
    copy_X.remove(X[i])
    print((copy_X[chu - 1]))
    


# Optimized solution
N,*X = list(map(int,open(0).read().split()))
chu = N//2 - 1
nums = sorted(X,reverse=True)
num, num_right = nums[chu], nums[chu + 1]
for x in X:
    print((num if x < num else num_right))
# Original solution
import statistics
N = int(eval(input()))
X = list(map(int,input().split()))

for n in range(N):
  Y = X[:]
  Y.pop(n)
  print((statistics.median(Y)))

# Optimized solution
eval(input())
x=list(map(int,input().split()))
z=sorted(x)[(len(x))//2-1:]
for c in x:print((z[c<=z[0]]))
# Original solution
from statistics import *
N = int(eval(input()))
X = list(map(int,input().split()))
Y = sorted(X)
m = median(X)

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

# Optimized solution
N = int(eval(input()))
X = list(map(int,input().split()))
Y = sorted(X)
m1 = Y[N//2-1]
m2 = Y[N//2]

for x in X:
  if x<m2:
    print(m2)
  else:
    print(m1)
# Original solution
#-*-coding:utf-8-*-

def main():
    N = int(eval(input()))
    x_list = list(map(int, input().split()))
    x_sort = x_list[:]
    x_sort.sort()
    med = (N // 2) -1
    threshold = x_sort[med]
    med_dict = {}

    for i in range(N):
        if x_list[i] in med_dict:
            print((med_dict[x_list[i]]))
        elif x_list[i] > threshold:
            print(threshold)
        else:
            removed_x_list = x_list[:]
            removed_x_list.remove(x_list[i])
            removed_x_list.sort()
            median = removed_x_list[med]
            med_dict[x_list[i]] = median
            print(median)
    
if __name__ == '__main__':
    main()

# Optimized solution
#-*-coding:utf-8-*-

def main():
    N = int(eval(input()))
    x_list = list(map(int, input().split()))
    x_list_sort = x_list[:]
    x_list_sort.sort()
    med1 = x_list_sort[(N//2)-1]
    med2 = x_list_sort[N//2]
    for i in x_list:
        if i <= med1:
            print(med2)
        elif i >= med2:
            print(med1)
            
if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
X = list(map(int,input().split()))
import copy
for i in range(N):
  ls = copy.copy(X)
  ls.pop(i)
  sorted_ls = sorted(ls)
  print((sorted_ls[((len(sorted_ls)+1)//2-1)]))

# Optimized solution
N = int(eval(input()))
X = list(map(int,input().split()))

sX = sorted(X)
small_median = sX[N//2-1]
large_median = sX[N//2]

for i in range(N):
  if X[i] <= small_median:
    print(large_median)
  else:
    print(small_median)
# Original solution
N = int(eval(input()))
X = list(map(int,input().split()))
SX = sorted(X)
m1,m2 = SX[N//2-1],SX[N//2]

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

# Optimized solution
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')
# Original solution
import statistics
N = int(eval(input()))
Xlist = list(map(int, input().split()))
for i in range(N):
    a = Xlist[0:i] + Xlist[i + 1:]
    print((statistics.median(a)))


# Optimized solution
N = int(eval(input()))
Xlist = list(map(int, input().split()))
X_sort = sorted(Xlist)
left_med = X_sort[N//2-1]
right_med = X_sort[N//2]
for i in range(N):
    if Xlist[i] <= left_med:
        print(right_med)
    else:
        print(left_med)
# Original solution
from copy import copy

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

for xi in X:
    Y = copy(X)
    Y.remove(xi)
    print((sorted(Y)[N // 2 - 1]))


# Optimized solution
N = int(eval(input()))
X = list(map(int, input().split()))

M_small = sorted(X)[N // 2 - 1]
M_large = sorted(X)[N // 2]

for xi in X:
    if xi <= M_small:
        print(M_large)
    else:
        print(M_small)
# Original solution
n = int(eval(input()))
x = list(map(int,input().split()))

x_sort = sorted(x[:])

for i in range(n):
    x_sort_temp = x_sort[:]
    x_sort_temp.remove(x[i])
    #print("x_sort_removed",x_sort_temp)
    print((x_sort_temp[(n-1)//2]))

# Optimized solution
n = int(eval(input()))
x = list(map(int,input().split()))

x_sort = sorted(x[:])
a,b = x_sort[n//2 - 1], x_sort[n//2]

for i in range(n):
    if x[i] <= a:
        print(b)
    else:
        print(a)
# Original solution
def medians(nums):
    n = len(nums)
    num_orig_pos = list(zip(nums, list(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 [x[0] for x in sorted(medians, key=lambda x: x[1])]


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

# Optimized solution
def medians(nums, n):
    median_left = nums[(n + 1)//2]
    median_right = nums[(n + 1)//2 - 1]
    return median_left, median_right


if __name__ == '__main__':
    n = int(input())
    nums = list(map(int, input().split()))
    median_left, median_right = medians(sorted(nums), n)
    for i in nums:
        print(median_left) if i < median_left else print(median_right)
# Original solution
import bisect

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

m = (n-1) // 2
 
x_sorted = sorted(x)

ans = []

for i in range(n):
    ind = bisect.bisect_left(x_sorted, x[i])
    ans.append(x_sorted[0:ind] + x_sorted[ind+1:])

for i in range(n):
    print((ans[i][m]))

# Optimized solution
n = int(eval(input()))
x = list(map(int, input().split()))

sorted_x = sorted(x)
l = sorted_x[n//2]
s = sorted_x[n//2-1]

for i in x:
    if i <= s:
        print(l)
    else:
        print(s)
# Original solution
n = int(eval(input()))
x = list(map(int, input().split()))

x_sorted = sorted(x)
l = x_sorted[n//2]
s = x_sorted[n//2-1]

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

# Optimized solution
n = int(eval(input()))
x = list(map(int, input().split()))

sorted_x = sorted(x)
r = sorted_x[n//2]
l = sorted_x[n//2-1]

for n in x:
    if n <= l:
        print(r)
    else:
        print(l)
# Original solution
a = int(eval(input()))
x = list(map(int, input().split()))
k = list(x)
p = list(x)
for i in range(a):
    del k[i]
    #print(k)
    k.sort()
    #print(k)
    if a%2==0:
        print((k[a//2-1]))
    else:
        print(((k[a//2]+k[a//2-1])/2))
    k = list(p)
    

# Optimized solution
n = int(eval(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)))
# Original solution
N = int(eval(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:
    index = sorted_inputs.index(item)
    if index <= N // 2 - 1:
        print(right)
    else:
        print(left)


# Optimized solution
N = int(eval(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)
# Original solution
import copy

input = open(0).read

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


def main():
    a = copy.copy(X)
    l, r = sorted(a)[N // 2 - 1:N // 2 + 1]

    print(('\n'.join([str(r) if x < r else str(l) for x in X])))
    return


main()


# Optimized solution
input = open(0).read

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


def main():
    l, r = sorted(X)[N // 2 - 1:N // 2 + 1]

    print(('\n'.join([str(r) if x < r else str(l) for x in X])))
    return


main()
# Original solution
from bisect import bisect_left
N = int(eval(input()))
X = list(map(int,input().split()))
subX = X[1:]
subX.sort()
for i in range(N-1):
    print((subX[N//2-1]))
    k = bisect_left(subX,X[i])
    subX.insert(k,X[i])
    k = bisect_left(subX,X[i+1])
    subX.pop(k)
print((subX[N//2-1]))


# Optimized solution
from bisect import bisect_left
N = int(eval(input()))
X = list(map(int,input().split()))
Y = X.copy()
Y.sort()
for i in range(N):
    k = bisect_left(Y,X[i])
    if k < N//2:
        print((Y[N//2]))
    else:
        print((Y[N//2-1]))
# Original solution
n = int(eval(input()))
x = list(map(int, input().split()))

for i in range(n):
    xx =list( x)
    xx.pop(i)
    xx=sorted(xx)
    print((xx[(n-1)//2]))

# Optimized solution
n = int(eval(input()))
xx = list(map(int, input().split()))
x=sorted(xx)

for i in range(n):
    if xx[i] < x[n //2]:
        print((x[n // 2]))
    else:
        print((x[(n - 1) // 2]))
# Original solution
import copy
N = int(eval(input()))
X = list(map(int,input().split()))


for i in range(N):
    Y = copy.copy(X)
    del Y[i]
    Y.sort()
    print((Y[N//2-1]))


# Optimized solution
N = int(eval(input()))
X = list(map(int,input().split()))
Y = sorted(X)
m1= Y[N//2-1]
m2 = Y[N//2]
for i in range(N):
    if X[i] <= m1:
        print(m2)
    else:
        print(m1)
# Original solution
import copy
N = int(eval(input()))
X = list(map(int,input().split()))
length = len(X)
 
 
for i in range(N):
    x = copy.copy(X) 
    x.pop(i)
    x.sort()
    print((x[int(length/2)-1]))
    # print(x,X)

# Optimized solution
N = int(eval(input()))
X = list(map(int,input().split()))

sortx = sorted(X)
bef = sortx[N//2-1]
aft = sortx[N//2]
for i in X:
        print((aft if i <= bef else bef))
# Original solution
import copy
a = int(eval(input()))
da = list(map(int,input().split()))
k = a//2
for i in range(a):
  n = copy.deepcopy(da)
  del n[i]
  n.sort()
  print((n[k-1]))

# Optimized solution
n = int(eval(input()))
aa = list(map(int,input().split()))
a = [[] for i in range(n)]
for i in range(n):
    a[i].append(aa[i])
    a[i].append(i)

a.sort()

mm = a[n//2-1][0]
m = a[n//2][0]
for i in range(n):
    a[i].append(i)
a.sort(key = lambda x:x[1])

for i in range(n):
    if a[i][2] <= n//2 -1:
        print(m) 
    else:
        print(mm)
# Original solution
import statistics
N = int(eval(input()))
X = list(map(int,input().split()))
for i in range(1,N+1):
    tmp = X[0:i-1]+X[i:]
    print((statistics.median(tmp)))

# Optimized solution
N = int(eval(input()))
X = list(map(int,input().split()))
a = sorted(X)
b = a[N//2]
c = a[(N//2)-1]
for i in X:
    print((b if i<b else c))
# Original solution
n = int(eval(input()))
x = list(map(int, input().split()))

for i in range(n):
    temp = sorted(x[:i] + x[i + 1:])
    ans = temp[n // 2 - 1]
    print(ans)


# Optimized solution
n = int(eval(input()))
x = list(map(int, input().split()))

y = sorted(x)
mid1 = y[(n + 1) // 2]
mid2 = y[(n - 1) // 2]

for i in range(n):
    if mid1 == mid2:
        ans = mid1
    elif x[i] >= mid1:
        ans = mid2
    elif x[i] <= mid2:
        ans = mid1

    print(ans)
# Original solution
N = int(eval(input()))
x = list(int(i) for i in input().split())
for i in range(N):
    a = x.pop(i)
    print((sorted(x)[int(N/2-1)]))
    x.insert(i,a)
    

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))

X = []
for i, a in enumerate(A):
    X.append([a, i])

X.sort()

# Biになり得るのはX[m-1] or X[m] (m=N//2)
m = N//2
itoj = {}
for j in range(N):
    x, i = X[j]
    itoj[i] = j
for i in range(N):
    j = itoj[i]
    if j < m:
        print((X[m][0]))
    else:
        print((X[m-1][0]))
# Original solution
n = int(eval(input()))
x = [int(i) for i in input().split()]

for i in range(n):
    print((sorted((x[:i] + x[i+1:]))[(n-1)//2]))

# Optimized solution
n = int(eval(input()))
x = [int(i) for i in input().split()]

sorted_x = sorted(x)
smaller = sorted_x[n//2 - 1]
bigger = sorted_x[n//2]

for i in range(n):
    print((bigger if x[i] <= smaller else smaller))
# Original solution
import statistics
import math
import copy

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

for i in range(n):
  tmp = copy.copy(x)
  tmp.pop(i)
  print((statistics.median(tmp)))


# Optimized solution

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

mid_1 = sort_x[n//2-1]
mid_2 = sort_x[n//2]

for i in range(n):
  
  if x[i] <= mid_1:
    print(mid_2)
  else:
    print(mid_1)
# Original solution
N=int(eval(input()))
X=list(map(int,input().split()))
list=sorted(X)

for i in X:
    if list.index(i)<N/2:
        print((list[N//2]))
    else:
        print((list[N//2-1]))

# Optimized solution
N=int(eval(input()))
X=list(map(int,input().split()))
list=sorted(X)

for i in range(N):
    if list[int((N/2))]<=X[i]:
        print((list[int(N/2)-1]))
    else:
        print((list[int(N/2)]))
# Original solution
N = int(eval(input()))
x = [i for i in map(int ,input().split())]
mid = (N-1) // 2
for i in range(N):
    tmp = x[:]
    tmp.remove(x[i])
    tmp.sort()
    print((tmp[mid]))

# Optimized solution
N = int(eval(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]))
# Original solution
n=int(eval(input()))
x=list(map(int,input().split()))
a=sorted(x)

for i in x:
    p=a.index(i)

    if p< n//2:
        print((a[n//2]))
    else:
        print((a[n//2-1]))
        
        

# Optimized solution
n=int(eval(input()))
x=list(map(int,input().split()))
a=sorted(x)
ans={}

for i in range(n):

    if i<n//2:
        ans[a[i]]=a[n//2]
    else:
        ans[a[i]]=a[n//2-1]

for j in x:
    print((ans[j]))
# Original solution
import copy
from statistics import median

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

y = copy.deepcopy(x)
for a in x:
    y.remove(a)
    print((median(y)))
    y.append(a)

# Optimized solution
import copy

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

if n == 2:
    print((x[1]))
    print((x[0]))
    exit()

y = copy.deepcopy(x)
y.sort()
mid_s = y[n // 2 - 1]
mid_l = y[n // 2]
for a in x:
    if a < mid_l:
        print(mid_l)
    else:
        print(mid_s)
# Original solution
N = int(eval(input()))
X = list(map(int, input().split()))
for i in range(N):
    tmp = sorted(X[:i] + X[i+1:])[::-1]
    print((tmp[(N-1)//2]))


# Optimized solution
N = int(eval(input()))
X = list(map(int, input().split()))
Y = sorted(X)
a, b = Y[N//2], Y[N//2-1]
for i in range(N):
    if X[i] < a:
        print(a)
    else:
        print(b)
# Original solution
n = int(eval(input()))
x = list(map(int, input().split()))

sortedx = x[:]
sortedx.sort()

for i in range(n):
    ix = sortedx.index(x[i])
    #print(sortedx)
    #print(ix)
    if ix < n/2:
        print((sortedx[n//2]))
    else:
        print((sortedx[n//2-1]))

# Optimized solution
n = int(eval(input()))
x = list(map(int, input().split()))

sortedx = x[:]
sortedx.sort()

for i in range(n):
    #ix = sortedx.index(x[i])
    #print(sortedx)
    #print(ix)
    if x[i] <= sortedx[n//2-1]:
        print((sortedx[n//2]))
    else:
        print((sortedx[n//2-1]))
# Original solution
n = int(eval(input()))
x = list(map(int, input().split()))

sortedx = x[:]
sortedx.sort()

for i in range(n):
    #ix = sortedx.index(x[i])
    #print(sortedx)
    #print(ix)
    if x[i] <= sortedx[n//2-1]:
        print((sortedx[n//2]))
    else:
        print((sortedx[n//2-1]))

# Optimized solution
n = int(eval(input()))
x = list(map(int, input().split()))
     
sx = sorted(x)
xm = sx[n//2-1]
xp = sx[n//2]
     
for i in range(n):
    if x[i] <= xm:
        b = xp
    else:
        b = xm
    print(b)
# Original solution
n = int(eval(input()))
x = list(map(int, input().split()))
ans = []
for i in range(n):
    xx = x.copy()
    delete = xx.pop(i)
    xxx = sorted(xx)
    print((xxx[(n-1)//2]))


# Optimized solution
n = int(eval(input()))
x = list(map(int, input().split()))
xsort = sorted(x)

n1, n2 = xsort[n//2-1], xsort[n//2]

for i in range(n):
    if x[i]  <= n1:
        print(n2)
    else:
        print(n1)
# Original solution
from collections import defaultdict
def main():
    N = int(eval(input()))
    X = [int(a) for a in input().split()]
    X_s = sorted(X)

    medi = defaultdict(int)

    for i in range(len(X)):
        if X[i] in list(medi.keys()):
            print((medi[X[i]]))
        else:
            dummy = X_s[:]
            dummy.remove(X[i])
            m = dummy[len(dummy) // 2]
            print(m)
            medi[X[i]] = m

if __name__ == "__main__":
    main()

# Optimized solution
def main():
    N = int(eval(input()))
    X = [int(a) for a in input().split()]
    Xs = sorted(X)

    for i in range(len(X)):
        if  Xs[len(Xs)//2] > X[i]:
            print((Xs[len(Xs)//2]))
        else:
            print((Xs[len(Xs)//2 - 1]))

if __name__ == "__main__":
    main()
# Original solution
def convert_X(x,index):
	if index == 0:
		return x[1:]
	if index == len(x)-1:
		return x[:-1]
	return x[:index] + x[index+1:]

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

for index in range(N):
	d_x = convert_X(X,index)
	d_x.sort()
	print((d_x[int( (len(d_x)+1)/2 ) -1]))


# Optimized solution
N = int(eval(input()))
X = [int(d) for d in input().split()]

sort_x = X.copy()
sort_x.sort()

nn = N//2
low_ = sort_x[nn-1]
high_ = sort_x[nn]

for x in X:
	if x < high_:
		print(high_)
	else:
		print(low_)
# Original solution
import statistics
import copy

n=int(eval(input()))
a=list(map(int,input().split()))
for i in range(n):
    l=copy.deepcopy(a)
    l.pop(i)
    l.sort()
    ans=l[n//2-1]
    print(ans)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
l=sorted(a)
x=l[n//2-1]
y=l[n//2]
for z in a:
    if z<=x:
        print(y)
    else:
        print(x)
# Original solution
import sys
import copy
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(eval(input()))
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()

B = copy.deepcopy(A)
B.sort()

med = N//2

for i,a in enumerate(A):
	if B.index(a)>=med:
		print((B[med-1]))
	else:
		print((B[med]))

# Optimized solution
import sys
import copy
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(eval(input()))
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()

# print(A)
med = N//2

B = copy.deepcopy(A)
B.sort()
l_m = B[med-1]
h_m = B[med]

for a in A:
	if a > l_m:
		print(l_m)
	else:
		print(h_m)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
for i in range(n):
    b=sorted(a[:i]+a[i+1:])
    print((b[n//2-1]))

# Optimized solution
n=int(eval(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))
# Original solution
n=int(eval(input()))
*x,=list(map(int,input().split()))
s=sorted(x)
for i in x:
	if s.index(i)<=(n//2)-1:
		print((s[n//2]))
	else:
		print((s[(n//2)-1]))

# Optimized solution
n=int(eval(input()))
*x,=list(map(int,input().split()))
s=sorted(x)
m=(s[n//2]+s[(n//2)-1])/2
for i in x:
	if i<m:
		print((s[n//2]))
	elif i==m:
		print(i)
	else: 
		print((s[(n//2)-1]))