n=input()
n=int(n)
a=[]
for i in range(n):
  s=input()
  a.append(s)
if int(max(a))>=0:
  m=max(a)
else:
  m=min(a)
k=a.index(m)
a.remove(m)
for j in range(k):
  print(m)
if int(max(a))>=0:
  print(max(a))
else:
  print(min(a))
for t in rang