N =int(input())
A = [0]*N
a = 0
b = 0
for i in range(N):
    x = int(input())
    if x > a:
        b = a
        a = x
    A[i] = x

for c in A:
    if c == a:
        print(b)
    else:
        print(a)