N = int(input())

A_i = []
for i in range(N):
    A_i.append(int(input()))

for i in range(N):
    A_i_copy = []
    if i == 0:
        A_i_copy = sorted(A_i[1:N])
    elif i == N - 1:
        A_i_copy = sorted(A_i[0:N-1])
    else:
        A_i_copy = sorted(A_i[0:i] + A_i[i+1:N])

    print(A_i_copy[N - 2])