import numpy as np

N = int(eval(input()))

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

a = max(num_list)

if num_list.count(a) > 1:

  for j in range(N):

    print(a)

else:

  b = np.sort(num_list)

  c = b[-2]

  for k in range(int(num_list.index(a))):

    print(a)

  print(c)

  for l in range(N-int(num_list.index(a))-1):

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

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

B = sorted(A,reverse=True)

max1 = B[0]

max2 = B[1]

for i in range(N):

    if A[i] == max1:

        print(max2)

    else:

        print(max1)
import numpy as np

N = int(eval(input()))
num_list = [int(eval(input())) for i in range(N)]
a = max(num_list)
if num_list.count(a) > 1:
    for j in range(N):
        print(a)
else:
    b = np.sort(num_list)
    c = b[-2]
    for k in range(int(num_list.index(a))):
        print(a)
    print(c)
    for l in range(N - int(num_list.index(a)) - 1):
        print(a)

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

-import numpy as np - -num_list = [int(eval(input())) for i in range(N)] -a = max(num_list) -if num_list.count(a) > 1: -    for j in range(N): -        print(a) -else: -    b = np.sort(num_list) -    c = b[-2] -    for k in range(int(num_list.index(a))): -        print(a) -    print(c) -    for l in range(N - int(num_list.index(a)) - 1): -        print(a) +A = [int(eval(input())) for i in range(N)] +B = sorted(A, reverse=True) +max1 = B[0] +max2 = B[1] +for i in range(N): +    if A[i] == max1: +        print(max2) +    else: +        print(max1)