from copy import copy

N = int(input())

A = [None]*N

for i in range(N):
    A[i] = int(input())

Asorted = sorted(A)
    
for i in range(N):
    Ai = A[i]
    Asortedcopy = copy(Asorted)
    Amax = Asortedcopy.pop()
    if Amax == Ai:
        Amax = Asortedcopy.pop()
    print(Amax)
