N = int(eval(input()))

A = []

for i in range(N):

    A.append(int(eval(input())))

B = sorted(A, reverse = True)



for i in range(N):

    if A[i] == B[0]:

        print((B[1]))

    else:

        print((B[0]))

import sys

input = sys.stdin.readline

N = int(eval(input()))

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

B = sorted(A, reverse = True)



for i in range(N):

    if A[i] == B[0]:

        print((B[1]))

    else:

        print((B[0]))

N = int(eval(input()))
A = []
for i in range(N):
    A.append(int(eval(input())))
B = sorted(A, reverse=True)
for i in range(N):
    if A[i] == B[0]:
        print((B[1]))
    else:
        print((B[0]))

import sys

input = sys.stdin.readline
N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
B = sorted(A, reverse=True)
for i in range(N):
    if A[i] == B[0]:
        print((B[1]))
    else:
        print((B[0]))

+import sys + +input = sys.stdin.readline -A = [] -for i in range(N): -    A.append(int(eval(input()))) +A = [int(eval(input())) for _ in range(N)]