n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
  if i == 0:
    ans = max(a[1:n])
  elif i == n-1:
    ans = max(a[0:n-1])
  else:
    ans = max(a[0:i],a[i+1:n])
  print(ans)