#C - Exception Handling
N = int(input())
A = list(int(input()) for _ in range(N))
A_sorted = list(set(sorted(A, reverse = False)))

ans = []
for i in A:
    A_copy = A.copy()
    A_copy.remove(i)
    ans.append(max(A_copy))

for i in ans:
    print(i)