import numpy as np



N = int(eval(input()))

A = np.zeros(N, np.int32)

for i in range(N):

  A[i] = int(eval(input()))



A_asc = np.sort(A)

max1 = A_asc[-1]

max2 = A_asc[-2]



for a in A:

  if a == max1:

    print(max2)

  else:

    print(max1)
N = int(eval(input()))

A = []

for i in range(N):

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



A_asc = sorted(A)

max1 = A_asc[-1]

max2 = A_asc[-2]



for a in A:

  if a == max1:

    print(max2)

  else:

    print(max1)
import numpy as np

N = int(eval(input()))
A = np.zeros(N, np.int32)
for i in range(N):
    A[i] = int(eval(input()))
A_asc = np.sort(A)
max1 = A_asc[-1]
max2 = A_asc[-2]
for a in A:
    if a == max1:
        print(max2)
    else:
        print(max1)

N = int(eval(input()))
A = []
for i in range(N):
    A.append(int(eval(input())))
A_asc = sorted(A)
max1 = A_asc[-1]
max2 = A_asc[-2]
for a in A:
    if a == max1:
        print(max2)
    else:
        print(max1)

-import numpy as np - -A = np.zeros(N, np.int32) +A = [] -    A[i] = int(eval(input())) -A_asc = np.sort(A) +    A.append(int(eval(input()))) +A_asc = sorted(A)