import copy
N = int(input())
A = []
B = []
for i in range(N):
    j = int(input())
    A.append(j)
    B.append(j)
B.sort(reverse=True)
B.pop(0)
for i in A:
    if i == max(A):
        print(i)
    else:
        print(max(B))