import numpy as np

def q46(n, a):
    a = np.array(a)
    m = max(a)
    for i in range(n):
        if a[i] < m:
            print(m)
        else:
            ind = np.ones(n, dtype=bool)
            ind[i] = False
            print(max(a[ind]))

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

q46(N, A)