CodeEff/ECCO huggingface dataset:
# Original solution
import copy
N = int(eval(input()))
X = list(map(int, input().split()))
for i in range(N):
    med = copy.deepcopy(X)
    med.pop(i)
    med.sort()
    print((med[int(N/2)-1]))

# Optimized solution
N = int(eval(input()))
X = list(map(int, input().split()))
Xsort = sorted(X)
med = (Xsort[N // 2] + Xsort[N // 2 - 1]) / 2
for i in range(N):
    if X[i] < med:
        print((Xsort[N // 2]))
    else:
        print((Xsort[N // 2-1]))
# Original solution
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

A = sorted(X)

med1 = A[N // 2 - 1] 
med2 = A[N // 2]

for i, x in enumerate(X):
    if x <= med1:
        print(med2)
    else:
        print(med1)

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

# Optimized solution
n = int(eval(input()))
x = list(map(int, input().split()))
y = sorted(x)
a = y[n // 2 - 1]
b = y[n // 2]
for i in x:
    print(((a, b)[i <= a]))
# Original solution
n = int(eval(input()))
xarray = list(map(int,input().split()))
newArray = xarray[:]
newArray.sort()


for item in xarray:
    if newArray.index(item)<=int(n/2-1):
        print((newArray[int(n/2)]))
    else:
        print((newArray[int(n/2)-1]))

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

for i in range(len(x)):
    tmp_list = x.copy()
    tmp_list.pop(i)
    tmp_list.sort()
    print((tmp_list[int(n/2-1)]))


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

min_mid = sx[int(n/2-1)]
max_mid = sx[int(n/2)]

for i in x:
    if i <= min_mid:    # 左半分から取られてる時
        print(max_mid)
    else:               # 右半分から取られてる時
        print(min_mid)
# Original solution
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(eval(input()))
    l=list(map(int,input().split()))
    l2=sorted(l)
    x=l2[n//2-1]
    y=l2[n//2]
    if x==y:
        for i in range(n):
            print(x)
    else:
        setx=set(l2[:n//2])
        sety=set(l2[n//2:])
        for i in l:
            if i in setx:
                print(y)
            else:
                print(x)
resolve()

# Optimized solution
import sys


def input(): return sys.stdin.readline().strip()


def resolve():
    n = int(eval(input()))
    l = list(map(int, input().split()))
    lsort = sorted(l)
    left = lsort[n // 2 - 1]
    right = lsort[n // 2]
    for i in l:
        if i <= left:
            print(right)
        else:
            print(left)
resolve()
# Original solution
n = int(eval(input()))
lst_x = list(map(int, input().split()))
lst = lst_x[:]
lst.sort()
b1 = lst[n//2 - 1]
b2 = lst[n//2]


for x in lst_x:
    if x <= b1:
        ans = b2
    else:
        ans = b1
    print(ans)

# Optimized solution
n = int(eval(input()))
lst_x = list(map(int, input().split()))
lst = lst_x[:]
lst.sort()
b1 = lst[n//2 - 1]
b2 = lst[n//2]


for x in lst_x:
    print((b2 if x <= b1 else b1))
# Original solution
def main():
    n = int(eval(input()))
    x = [int(xn) for xn in input().split()]
    x_sorted = sorted(x)
    idx_median = (n - 1) // 2
    for xn in x:
        target = [*x_sorted]
        target.remove(xn)
        print((target[idx_median]))


if __name__ == '__main__':
    main()


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


if __name__ == '__main__':
    main()
# Original solution

import copy

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

def medianIndex(l, i):
    l.pop(i-1)
    num = len(l)
    l.sort()
    m = int((num - 1) / 2)
    print((l[m]))
    

for i in range(1,n+1):
    temp = copy.copy(x)
    medianIndex(temp, i)

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

y = copy.copy(x)
x.sort()
l = len(x)
m0 = x[int(l/2 - 1)]
m1 = x[int(l/2)]


for i in y:
    if i <= m0:
        print(m1)
    else:
        print(m0)
# Original solution
import sys

read = sys.stdin.buffer.read

n,*x = list(map(int, read().split()))


for i in range(0,n):
  temp = []
  try:
    temp = x[:i]
  except:
    pass
  try:
    temp += x[i+1:]
  except:
    pass
  temp.sort()
  print((temp[n//2-1]))

# Optimized solution
import sys

read = sys.stdin.buffer.read

n,*x = list(map(int, read().split()))
x_sort = sorted(x)

mean_left = x_sort[n//2-1]
mean_right = x_sort[n//2]


for i in range(n):
  if x[i] <= mean_left:
    print(mean_right)
  elif x[i] >= mean_right:
    print(mean_left)
# Original solution
# ABC094C - Many Medians (ARC095C)
def main():
    N, *X = map(int, open(0).read().split())
    l, h = sorted(X)[N // 2 - 1 : N // 2 + 1]
    ans = [h if i <= l else l for i in X]
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()


# Optimized solution
# ABC094C - Many Medians (ARC095C)
def main():
    N, *X = list(map(int, open(0).read().split()))
    l, h = sorted(X)[N // 2 - 1 : N // 2 + 1]
    ans = [h if i <= l else l for i in X]
    print(("\n".join(map(str, ans))))


if __name__ == "__main__":
    main()
# Original solution
n = int(eval(input()))
ls = [x for x in map(int, input().split(' '))]
for x in range(0, n):
    dam = ls.copy()
    del dam[x]
    dam = sorted(dam)
    print((dam[int(len(dam)/ 2)]))

# Optimized solution
n = int(eval(input()))
ls = [x for x in map(int, input().split(' '))]
dam = sorted(ls.copy())

for x in range(0, n):
    if ls[x] < dam[n // 2]:
        print((dam[n // 2]))
    else:
        print((dam[(n // 2) - 1]))
# Original solution
n = int(eval(input()))
xlst = list(map(int, input().split()))

for i in range(n):
    x_ = xlst.copy()
    x_.pop(i)
    x_.sort(reverse=True)
    print((x_[n//2-1]))


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

l = xl_s[n//2-1]
r = xl_s[n//2]

for x in xl:
    if x >= r:
        print(l)
    else:
        print(r)
# Original solution
N=int(eval(input()))
x=list(map(int,input().split()))
l=[]       
for i in range(N):
    temp=[]
    for j in range(N):
        if i!=j:
            temp.append(x[j])
    l.append(temp)
length=N-1

for i in range(N):
    l[i]=sorted(l[i])
    print((l[i][(length+1)//2-1]))


# Optimized solution
N=int(eval(input()))
x=list(map(int,input().split()))
y=sorted(x)
left=y[N//2-1]
right=y[N//2]

for i in x:
    if i<=left:
        print(right)
    elif i>=right:
        print(left)
# Original solution
#!/usr/bin/env python
# coding: utf-8

# In[2]:


import copy


# In[10]:


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


# In[11]:


for i in range(N):
    x_copy = copy.deepcopy(X)
    del x_copy[i]
    ans = sorted(x_copy)[N//2-1]
    print(ans)


# In[ ]:






# Optimized solution
#!/usr/bin/env python
# coding: utf-8

# In[25]:


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


# In[26]:


x1 = sorted(X)[N//2-1]
x2 = sorted(X)[N//2]
for i in range(N):
    if X[i] >= x2:
        print(x1)
    else:
        print(x2)


# In[ ]:
# Original solution
import copy

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

for i in range(N // 2 + 1):
    for j in range(N - 1 - i):
        if(S_X[j] > S_X[j + 1]):
            tmp = S_X[j + 1]
            S_X[j + 1] = S_X[j]
            S_X[j] = tmp
# s_X = sorted(X)
miX = S_X[N // 2 - 1]
mi1X = S_X[N // 2]
# print(S_X, X)
# print(miX, mi1X)

# print(miX, mi1X)
# print(X)
for a in X:
    if(a <= miX):
        print(mi1X)
    else:
        print(miX)

# Optimized solution
# import copy

N = int(eval(input()))
X = list(map(int, input().split()))
# S_X = copy.copy(X)
S_X = sorted(X)
miX = S_X[N // 2 - 1]
mi1X = S_X[N // 2]
# print(S_X, X)
# print(miX, mi1X)

# print(miX, mi1X)
# print(X)
for a in X:
    if(a <= miX):
        print(mi1X)
    else:
        print(miX)
# Original solution
n = int(eval(input()))

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


for i in range(len(argList)):
    argList2 = argList.copy()
    argList2.pop(i)
    argList2.sort()
    print((argList2[int(len(argList2)/2)]))


# Optimized solution
n = int(eval(input()))

argList = list(map(int, input().split()))
argList2 = argList.copy()
argList2.sort()

med_before = argList2[int(len(argList2)/2)-2]
med = argList2[int(len(argList2)/2)-1]
med_after = argList2[int(len(argList2)/2)]

for a in argList:
    if( a <= med):
        print(med_after)
    else:
        print(med)
# Original solution
n=int(eval(input()))
x=list(map(int, input().split()))
ll=(len(x)-1)//2

for i in range(n):
    xx=x.copy()
    del xx[i]
    xx=sorted(xx,reverse=True)
    print((xx[ll]))

# Optimized solution
n=int(eval(input()))
x=list(map(int, input().split()))
xx=sorted(x,reverse=True)
ll=(len(x)-1)//2
for i in range(n):
    if x[i]<xx[ll]:
        print((xx[ll]))
    else:
        print((xx[ll+1]))
# Original solution
n=int(eval(input()))
x=list(map(int, input().split()))
xx=sorted(x,reverse=True)
ll=(len(x)-1)//2
for i in range(n):
    if x[i]<xx[ll]:
        print((xx[ll]))
    else:
        print((xx[ll+1]))

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

X_sort = sorted(X)

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




# Optimized solution
n = int(eval(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]))
# Original solution
N = int(eval(input()))
X = [int(i) for i in input().split()]
for i in range(N):
    start = i + 1
    x = sorted(X[:i] + X[start:])
    l = len(x)
    b = (l + 1) // 2
    print((x[b - 1]))


# Optimized solution
n = int(eval(input()))
x = [int(i) for i in input().split()]
xsort = sorted(x)
l1 = xsort[n // 2 - 1]
l2 = xsort[n // 2]
for i in range(n):
    print((l1 if x[i] >= l2 else l2))
# Original solution
def main():
    N = int(eval(input()))
    X = [int(x) for x in input().split()]
    Xsort = sorted(X)
    for i in range(N):
        if X[i] <= Xsort[N//2-1]:
            print((Xsort[N//2]))
        else:
            print((Xsort[N//2-1]))

if __name__ == '__main__':
    main()


# Optimized solution
def main():

    N = int(eval(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//2-1]))

if __name__ == '__main__':
    # print(main())
    main()
# Original solution
n = int(eval(input()))
x = list(map(int,input().split()))

for i in range(n):
    b=x.pop(i)
    print((sorted(x)[int(n/2)-1]))
    #print(a[int(n/2)-1])
    x.insert(i,b)

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

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

sorted_x = sorted(X)

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

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

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

sorted_x = sorted(X)

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

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


# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=sorted(a)
p,q=b[n//2-1],b[n//2]
for i in a:print((p if i>=q else q))
# Original solution
import copy
n = int(eval(input()))
x = list(map(int, input().split()))

middle = int(n/2) - 1
for i in range(n):
  copy_list = copy.copy(x)
  elm = copy_list.pop(i)
  print((sorted(copy_list).pop(middle)))


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

middle = int(n/2) - 1
next_middle = middle + 1

for i in range(n):
  if x[i] <= sort_x[middle]:
    print((sort_x[next_middle]))
  elif x[i] >= sort_x[next_middle]:
    print((sort_x[middle]))
# Original solution
def main():
    c = int(eval(input())) // 2
    elem = list(map(int, input().split()))
    right, left = sorted(elem)[c - 1:c + 1]
    for val in elem:
        print((median(val, right, left)))


def median(val, right, left):
    if right == left:
        return right
    elif val <= right:
        return left
    else:
        return right


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    c = int(eval(input())) // 2
    elem = list(map(int, input().split()))
    right, left = sorted(elem)[c - 1:c + 1]
    for val in elem:
        print((median(val, right, left)))


def median(val, right, left):
    if val <= right:
        return left
    else:
        return right


if __name__ == '__main__':
    main()
# Original solution
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(eval(input()))
    X = readInts()

    import statistics

    for i in range(n):
        A = (X[:i] + X[i+1:] if i+1 < n else X[:i])
        print((statistics.median(A)))




if __name__ == '__main__':
  main()


# Optimized solution
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(eval(input()))
    X = readInts()

    A = sorted(X)[n//2-1:n//2+1] # 中央値のどちらか
    #print(A)
    for x in X:
        #print(x <= A[0]) # False 0 True 1
        print((A[x <= A[0]])) # 1




if __name__ == '__main__':
  main()
# Original solution
n=int(eval(input()))
pos=n//2-1
arr=list(map(int,input().split()))
for i in range(n):
  arr[i]=[arr[i],i]
arr=sorted(arr,key=lambda x:x[0])
ans=[0]*n
for i in range(n):
  tmp=arr[:i]+arr[i+1:]
  ans[arr[i][1]]=tmp[pos][0]
for i in range(n):
  print((ans[i]))

# Optimized solution
n=int(eval(input()))
pos=n//2-1
arr=list(map(int,input().split()))
for i in range(n):
  arr[i]=[arr[i],i]
arr=sorted(arr,key=lambda x:x[0])
ans=[0]*n
for i in range(n):
  if i<=pos:
    ans[arr[i][1]]=arr[pos+1][0]
  else:
    ans[arr[i][1]]=arr[pos][0]
for i in range(n):
  print((ans[i]))
# Original solution
def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    b = sorted(a)
    
    def seach(x):
        l = 0
        r = n - 1
        while True:
            i = (l + r) // 2
            if r - l <= 1:
                if b[r] == x:
                    return r
                else:
                    return l
            if b[i] < x:
                l = i
            elif b[i] > x:
                r = i
            else: 
                return i
    
    for i in range(n):
        j = seach(a[i])
        c = b[:j] + b[j+1:]
        print((c[n // 2 - 1]))

        
if __name__ == '__main__':
    main()

# Optimized solution
def main():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    b = sorted(a)
    
    for i in range(n):
        if a[i] <=  b[n // 2 - 1]:
            print((b[n // 2]))
        elif a[i] >  b[n // 2 - 1]:
            print((b[n // 2 - 1]))
        
        
if __name__ == '__main__':
    main()
# Original solution
from statistics import median

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

def naive(x):
    return [median(x[:i] + x[i+1:]) for i in range(len(x))]

for i in naive(x):
    print(i)

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

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

for i in range(n):
    if x[i] <= b:
        print(a)
    else:
        print(b)
# Original solution
n = int(eval(input()))
x = list(map(int,input().split()))

for i in range(n):
    ls = x[:(i)] + x[(i+1):]
    ls.sort()
    print((ls[int(n/2-1)]))

# Optimized solution
n = int(eval(input()))
x = list(map(int,input().split()))
ls = sorted(x)
a = ls[int(n/2-1)]
b = ls[int(n/2)]


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

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

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

x_sorted = sorted(x)

for i in range(n):
    l = x_sorted.copy()
    l.remove(x[i])
    print((l[int(n/2)-1]))



# Optimized solution
n = int(eval(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]))
# Original solution
n = int(eval(input()))
x = list(map(int,input().split()))
for i in range(n):
    a = x[:i] + x[i+1:]
    a.sort(reverse=True)
    print((a[n//2-1]))

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

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

num=[i+1 for i in range(N)]
l=list(zip(num,X))
l=sorted(l,key=lambda x:x[1])
indexlist=[]
for i in range(N):
    indexlist.append(l[i][0])
for i in range(N):
    x=indexlist.index(i+1)
    if x<=N//2-1:
        ans=l[N//2][1]
    else:
        ans=l[N//2-1][1]
    print(ans)

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

# Xをソート(Xsort)
# 除く数字が中央より左の場合、答えは中央右(r)の数字
# 逆も然り
Xsort=sorted(X)
l=(N-1)//2
r=l+1
th=Xsort[l]
for i in range(N):
    if X[i]<=th:
        ans=Xsort[r]
    else:
        ans=Xsort[l]
    print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

for i in range(n):
    b = list(a)
    del b[i]
    b.sort()
    print((b[int((n - 1) / 2)]))

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

b = sorted(a)
m1 = b[n // 2]
m2 = b[n // 2 - 1]

for num in a:
    if(num < m1):
        print(m1)
    else:
        print(m2)
# Original solution
n = int(eval(input()))
x = list(map(int,input().split()))
for i in range(n):
    xx = x[:i] + x[i+1:]
    xx.sort()
    print((xx[n//2 - 1]))


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

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

idx = [i for i in range(n)]
c = list(zip(x, idx))
c = sorted(c,key=itemgetter(0))
x, idx = list(zip(*c))

medi1 = x[len(x)//2]
medi2 = x[len(x)//2-1]

for i in range(len(x)):
    if idx.index(i)<len(x)//2:
        print(medi1)
    else:
        print(medi2)

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

x = [(j, i) for i, j in enumerate(x)]
x.sort(key=itemgetter(0))
medi1 = x[len(x)//2][0]
medi2 = x[len(x)//2-1][0]
ans = [0]*n
for i in range(len(x)):
    if i<len(x)//2:
        ans[x[i][1]] = medi1
    else:
        ans[x[i][1]] = medi2

for a in ans:
    print(a)
# Original solution
n = int(eval(input()))
x = list(map(int, input().split()))

m = (n-1)//2
l = sorted(x)
for i in x:
  if i > l[m]: print((l[m]))
  else: print((l[m+1]))

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

l = sorted(x)
m1 = l[(n-1)//2]
m2 = l[(n-1)//2+1]
for i in x:
  if i <= m1: print(m2)
  else: print(m1)
# Original solution
n = int(eval(input()))
x = list(map(int,input().split()))
for i in range(n):
	L = x[:i] + x[i+1:]
	M = sorted(L)
	print((M[n//2-1]))

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

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

print((statistics.median(x[1:])))

for i in range(1,n-1):
    print((statistics.median(x[0:i]+x[i+1:])))

print((statistics.median(x[0:n-1])))


# Optimized solution
import statistics

n = int(eval(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)
# Original solution
import sys
import statistics
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N = int(readline())
    X = list(map(int, readline().split()))
    sort_X = sorted(X)
    for i in range(N):
        median = statistics.median(X[:i]+X[i+1:])
        print(median)


if __name__ == '__main__':
    main()

# Optimized solution
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N = int(readline())
    X = list(map(int, readline().split()))
    sort_X = sorted(X)
    if N%2==0:
        med_l = sort_X[N//2-1]
        med_r = sort_X[N//2]
        for i in range(N):
            if X[i]<=med_l:
                print(med_r)
            else:
                print(med_l)
    else:
        l = sort_X[N//2-1]
        m = sort_X[N//2]
        r = sort_X[N//2+1]
        for i in range(N):
            if X[i]<=l:
                print(((m+r)/2))
            elif X[i]==m:
                print(((l+r)/2))
            else:
                print(((l+m)/2))


if __name__ == '__main__':
    main()
# Original solution
from statistics import median

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

for i in range(N):
    print((median(num_lis[:i] + num_lis[i + 1:])))

# Optimized solution

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

one = N // 2 - 1
two = N // 2

for x in X:
    if x <= tmp[one]:
        print((tmp[two]))
    else:
        print((tmp[one]))
# Original solution
import statistics
import copy
N = int(eval(input()))
X = list(map(int,input().split(" ")))
Y = copy.deepcopy(X)
Y.sort()
for i in range(N):
    Z = copy.deepcopy(Y)
    Z.remove(X[i])
    print((Z[N//2-1]))


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