N = int(input())
A = []
max_a = 0
max_index = 0

for i in range(0, N):
    ai = int(input())
    A.append(ai)
    if max_a < ai:
        max_a = ai
        max_index = i

A.remove(max_a)

for i in range(0, N):
    if i != max_index:
        print(max_a)
    else:
        print(max(A))


