import math

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

maxA = max(A)

for i in range(N):
    if A[i] != maxA:
        print(maxA)
    else:
        a = [x for x in A if A[i] != x]
        if a == []:
            print(maxA)
        else:
            print(max(a))

