from collections import *
import sys
inp = raw_input

def err(s):
    sys.stderr.write('{}\n'.format(s))

def ni():
    return int(inp())

def nl():
    return [int(_) for _ in inp().split()]

N = ni()
A = [ni() for _ in range(N)]

A2 = list(A)
A2.sort()
for ai in A:
    if ai == A2[-1]:
        print(A2[-2])
    else:
        print(A2[-1])

