import copy

N = int(input())

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

max_a = max(A)

for i in range(N):
    if(A[i] != max_a):
        print(max_a)
    else:
        B = copy.deepcopy(A)
        B.pop(i)
        print(max(B))
