n = int(input())
l1 = []
l2 = []
for i in range(n):
    l1.append(int(input()))
l2 = sorted(l1)
for i in range(n):
    m = max(l1)
    if (m == l1[i]):
        print(l2[1])
    else:
        print(m)
