N = int(eval(input()))

A = []

B = []

for _ in range(N):

    temp = int(eval(input()))

    A.append(temp)

    B.append(temp)



B.sort(reverse=True)

max_first = B[0]

max_second = B[1]



for i in range(N):

    if A[i] == max_first:

        print(max_second)

    else:

        print(max_first)
import copy

 

N=int(eval(input()))

A=[]

for _ in range(N):

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

 

A_max=max(A)

#ind_max=A.index(A_max)

B=copy.copy(A)

B.remove(A_max)

B_max=max(B)

 

for i in range(N):

    if A[i]!=A_max:

        print(A_max)

    else:

        print(B_max)
N = int(eval(input()))
A = []
B = []
for _ in range(N):
    temp = int(eval(input()))
    A.append(temp)
    B.append(temp)
B.sort(reverse=True)
max_first = B[0]
max_second = B[1]
for i in range(N):
    if A[i] == max_first:
        print(max_second)
    else:
        print(max_first)

import copy

N = int(eval(input()))
A = []
for _ in range(N):
    A.append(int(eval(input())))
A_max = max(A)
# ind_max=A.index(A_max)
B = copy.copy(A)
B.remove(A_max)
B_max = max(B)
for i in range(N):
    if A[i] != A_max:
        print(A_max)
    else:
        print(B_max)

+import copy + -B = [] -    temp = int(eval(input())) -    A.append(temp) -    B.append(temp) -B.sort(reverse=True) -max_first = B[0] -max_second = B[1] +    A.append(int(eval(input()))) +A_max = max(A) +# ind_max=A.index(A_max) +B = copy.copy(A) +B.remove(A_max) +B_max = max(B) -    if A[i] == max_first: -        print(max_second) +    if A[i] != A_max: +        print(A_max) -        print(max_first) +        print(B_max)