import numpy as np

S = input()
N = int(S)

A = np.zeros([N])
A_temp = np.zeros([N])

for i in range(0, N, 1):
    A[i] = int(input())

max = 0

index_max = np.argmax(A)

for i in range(0, N, 1):
    A_temp = np.copy(A)
    if index_max != i:
        print(int(A_temp[index_max]))
    else:
        A_temp[i] = 0
        print(A_temp)
        print(int(np.amax(A_temp)))
