n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
  
for i in range(n):
  if i==0:
    temp = a[1:]
  elif i==n-1:
    temp = a[:i]
  else:
    temp = a[:i]+a[i+1:]
  print(max(temp))