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)