#n,k = list(map(int,input().split(" ")))
"""n = int(input())
print(3*(n*n))
"""
"""
import math as m
N,D = list(map(int,input().split(" ")))
print(m.ceil(N / (2*D+1)))
"""

N = int(input())
l = []
nums = []
for i in range(N):
    Ai = int(input())
    nums.append(Ai)
    l.append(Ai)
for i in range(N):
    n = l[i]
    nl = sorted(l)
    m = nl[-1]
    if m == n:
        m = nl[-2]
    print(m)

