#coding : utf-8



import os

import sys



N = int(eval(input()))



A = []



for i in range(N):

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



X = [[A[i], i] for i in range(N)]





X.sort(key = lambda x: x[0], reverse=True)





for i in range(N):

	if i != X[0][1]:

		print((X[0][0]))

	else:

		print((X[1][0]))



#coding : utf-8



import os

import sys



N = int(eval(input()))



A = []



for i in range(N):

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





Amax = max(A)



i = A.index(Amax)

t = A[i]

A[i] = 0

A2nd = max(A)

A[i] = t



for i in range(N):

	if A[i] == Amax:

		print(A2nd)

	else:

		print(Amax)



# coding : utf-8
import os
import sys

N = int(eval(input()))
A = []
for i in range(N):
    A.append(int(eval(input())))
X = [[A[i], i] for i in range(N)]
X.sort(key=lambda x: x[0], reverse=True)
for i in range(N):
    if i != X[0][1]:
        print((X[0][0]))
    else:
        print((X[1][0]))

# coding : utf-8
import os
import sys

N = int(eval(input()))
A = []
for i in range(N):
    A.append(int(eval(input())))
Amax = max(A)
i = A.index(Amax)
t = A[i]
A[i] = 0
A2nd = max(A)
A[i] = t
for i in range(N):
    if A[i] == Amax:
        print(A2nd)
    else:
        print(Amax)

-X = [[A[i], i] for i in range(N)] -X.sort(key=lambda x: x[0], reverse=True) +Amax = max(A) +i = A.index(Amax) +t = A[i] +A[i] = 0 +A2nd = max(A) +A[i] = t -    if i != X[0][1]: -        print((X[0][0])) +    if A[i] == Amax: +        print(A2nd) -        print((X[1][0])) +        print(Amax)