import math
input = raw_input

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

A.sort(key = lambda x: x[1])

for xx in range(N):
    if A[-1][0] != xx:
        print(A[-1][1])
    else:
        print(A[-2][1])
