import sequtils,strutils,algorithm
var
    N = stdin.readline.parseInt
    A = newSeq[int](0)
    a : int

for i in 1..N:
    a = stdin.readline.parseInt
    A.add(a)
var B = sorted(A)
for i in 0..<N:
    if B[^1] == A[i]:
        echo B[^2]
    else:
        echo B[^1]
