import numpy as np


def resolve():
    N = int(input())
    A = [int(input()) for i in range(N)]
    A = np.array(A)
    idx = np.argsort(A)[::-1]
    A = A[idx]
    for i in range(N):
        print(A[np.where(idx != i)[0][0]])
        
resolve()