N = int(input())
A = []
for i in range(N):
  A.append(input())
 
B = sorted(A, reverse=True, key=number)
max_first = B[0]
max_second = B[1]
max_third = B[2]
 
for i in range(N):
    if A[i] != max_first:
        print(max_first)
    elif A[i] != max_second:
        print(max_second)
    else:
        print(max_third)