n = int(input())
a = []
b = []

for i in range(n):
    s = int(input())
    a.append(s)
    b.append(s)
    
b.sort()
b.reverse()

for i in range(n):
    if not b[0] == b[i]:
        c = b[i]
        break
    else:
        c = b[0]

for i in range(n):
    if not b[0] == a[i]:
        print(b[0])
    else:
        print(c)
