N = int(eval(input()))

a=[]

for i in range(N):

  a.append(int(eval(input())))



a1=max(a)

b=sorted(a)

a2=b[N-2]



for j in range(N):

  if a[j] != a1:

    print(a1)

  else:

    print(a2)
# coding: utf-8

# Your code here!

N=int(eval(input()))

A=[0]*N

for i in range(N):

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

m=sorted(A)[N-1]

m_=A.index(m)

m2=sorted(A)[N-2]

m2_=A.index(m2)

for i in range(N):

    if i!=m_:

        print(m)

    else:

        print(m2)
N = int(eval(input()))
a = []
for i in range(N):
    a.append(int(eval(input())))
a1 = max(a)
b = sorted(a)
a2 = b[N - 2]
for j in range(N):
    if a[j] != a1:
        print(a1)
    else:
        print(a2)

# coding: utf-8
# Your code here!
N = int(eval(input()))
A = [0] * N
for i in range(N):
    A[i] = int(eval(input()))
m = sorted(A)[N - 1]
m_ = A.index(m)
m2 = sorted(A)[N - 2]
m2_ = A.index(m2)
for i in range(N):
    if i != m_:
        print(m)
    else:
        print(m2)

+# coding: utf-8 +# Your code here! -a = [] +A = [0] * N -    a.append(int(eval(input()))) -a1 = max(a) -b = sorted(a) -a2 = b[N - 2] -for j in range(N): -    if a[j] != a1: -        print(a1) +    A[i] = int(eval(input())) +m = sorted(A)[N - 1] +m_ = A.index(m) +m2 = sorted(A)[N - 2] +m2_ = A.index(m2) +for i in range(N): +    if i != m_: +        print(m) -        print(a2) +        print(m2)