n=int(input())
lst=[int(input()) for i in range(n)]
for j in range(n):
  if j==0:
    print(max(lst[1:]))
  elif j==n-1:
    print(max(lst[:n]))
  else:
    a=max(lst[:j])
    b=max(lst[j+1:])
    print(max(a,b))