N= int(eval(input()))

A=[]

for x in range(0,N):

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

B=sorted(A)

for x in range(0,N):

    if A[x]==B[N-1]:

        print((B[N-2]))

    else:

        print((B[N-1]))

n=int(eval(input()))

a=int(eval(input()))

f,v,w=0,a,a

a=int(eval(input()))

if a>=v:

    w,v,f=v,a,1

else:

    w=a

for i in range(2,n):

    a=int(eval(input()))

    if a>=v:

        w,v,f=v,a,i

    elif a>=w:

        w=a

for i in range(n):

    if i==f:

        print(w)

    else:

        print(v)
N = int(eval(input()))
A = []
for x in range(0, N):
    A.append(int(eval(input())))
B = sorted(A)
for x in range(0, N):
    if A[x] == B[N - 1]:
        print((B[N - 2]))
    else:
        print((B[N - 1]))

n = int(eval(input()))
a = int(eval(input()))
f, v, w = 0, a, a
a = int(eval(input()))
if a >= v:
    w, v, f = v, a, 1
else:
    w = a
for i in range(2, n):
    a = int(eval(input()))
    if a >= v:
        w, v, f = v, a, i
    elif a >= w:
        w = a
for i in range(n):
    if i == f:
        print(w)
    else:
        print(v)

-N = int(eval(input())) -A = [] -for x in range(0, N): -    A.append(int(eval(input()))) -B = sorted(A) -for x in range(0, N): -    if A[x] == B[N - 1]: -        print((B[N - 2])) +n = int(eval(input())) +a = int(eval(input())) +f, v, w = 0, a, a +a = int(eval(input())) +if a >= v: +    w, v, f = v, a, 1 +else: +    w = a +for i in range(2, n): +    a = int(eval(input())) +    if a >= v: +        w, v, f = v, a, i +    elif a >= w: +        w = a +for i in range(n): +    if i == f: +        print(w) -        print((B[N - 1])) +        print(v)