import numpy as np

n = int(input())
A = np.array(list(int(input()) for i in range(n)))
A_max = np.array([max(A)]*n)
A_dif = A - A_max
for i in range(n):
    if A_dif[i]<0:
        print(A_max)
    else:
        A_copy = A.copy()
        A_del = np.delete(A_copy, i)
        print(max(A_del))