a = []
t = int(input())
for i in range(t):
    a.append(int(input()))

m = max(a)
try:
    b = sorted(list(set(a)))[-2]
except:
    b = m

for i in range(t):
    if a[i] != m:
        print(m)
    else:
        print(b)