import sys
input = sys.stdin.readline

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

for i in range(n):
    c = sorted(a,reverse = True)
    if c[0] == a[i]:
        b = c[1]
    else:
        b = c[0]
    print(b)