N = int(input())
A = []
for i in range(N):
    A.append(input())
A_sort = sorted(A)

for i in range(N):
    if A[i] != A_sort[N-1]:
        print(A_sort[N-1])
    else:
        print(A_sort[N-2])
    