import sys
input = sys.stdin.readline
N = int(input())
a = [int(input()) for i in range(N)]

b = sorted(a)
for i in range(N):
    if i == a.index(max(a)):
        print(b[-2])
    else:
        print(b[-1])