N=int(input())
L=[]
T=[]
for _ in range(N):
  x=int(input())
  L.append(x)
  if x not in T:
    T.append(x)

T.sort()
if not L.count(T[len(T)-1])<N//75:
  T.reverse()

for i in range(N):
  for j in range(len(T)):
    if T[j]!=L[i]:
      print(T[j])
      break
    elif len(T)==1:
      print(T[j])