import numpy as np

def q46(n, a):
    a = np.array(a)
    for i in range(n):
        ind = np.ones(n, dtype=bool)
        ind[i] = False

        print(max(a[ind]))
        #print(del a[i:i])
N = int(input())
A =[]
for i in range(N):
    A.append(int(input()))

q46(N, A)