n=int(input())
A=[]
B=[]
for i in range(n):
  a=int(input())
  A.append(a)
B=sorted(list(set(A)))[::-1]
for i in range(n):
  if B[0]==A[i]:
    if len(B)==1:
      print(B[0])
    else:
      print(B[1])
  else:
    print(B[0])