# coding: utf-8
N = int(input())
A = []
B = []
for i in range(N):
    A.append([int(input()), i])
A.sort(key=lambda x: x[0])
for i in range(N):
    if A[i][1] != N-1:
        print(A[N-1][0])
    else:
        print(A[N-2][0])