N = int(eval(input()))

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

A_sorted = sorted(A.copy())



for a in A:

    if a == A_sorted[-1]:

        print((A_sorted[-2]))

    else:

        print((A_sorted[-1]))
n = int(eval(input()))

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

A2 = sorted(A, reverse = True)



for i in range(n):

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

        print((A2[1]))

    else:

        print((A2[0]))
N = int(eval(input()))
A = [int(eval(input())) for i in range(N)]
A_sorted = sorted(A.copy())
for a in A:
    if a == A_sorted[-1]:
        print((A_sorted[-2]))
    else:
        print((A_sorted[-1]))

n = int(eval(input()))
A = [int(eval(input())) for i in range(n)]
A2 = sorted(A, reverse=True)
for i in range(n):
    if A[i] == A2[0]:
        print((A2[1]))
    else:
        print((A2[0]))

-N = int(eval(input())) -A = [int(eval(input())) for i in range(N)] -A_sorted = sorted(A.copy()) -for a in A: -    if a == A_sorted[-1]: -        print((A_sorted[-2])) +n = int(eval(input())) +A = [int(eval(input())) for i in range(n)] +A2 = sorted(A, reverse=True) +for i in range(n): +    if A[i] == A2[0]: +        print((A2[1])) -        print((A_sorted[-1])) +        print((A2[0]))