import copy
n = int(input())
al = []
for _ in range(n):
    al.append(int(input()))

alcopy = copy.deepcopy(al)
alcopy.sort()
for a in al:
    if a != max(al):
        print(max(al))
    else:
        print(alcopy[-2])