import numpy as np

n=int(eval(input()))

a=[int(eval(input())) for i in range(n)]

a_=sorted(a)

m=max(a)

for i in range(n):

  if a[i]!=m:

    print(m)

  else:

    print((a_[-2]))


n=int(eval(input()))

a=[int(eval(input())) for i in range(n)]

a_=sorted(a)

m=a_[-1]

for i in range(n):

  if a[i]!=m:

    print(m)

  else:

    print((a_[-2]))
import numpy as np

n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
a_ = sorted(a)
m = max(a)
for i in range(n):
    if a[i] != m:
        print(m)
    else:
        print((a_[-2]))

n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
a_ = sorted(a)
m = a_[-1]
for i in range(n):
    if a[i] != m:
        print(m)
    else:
        print((a_[-2]))

-import numpy as np - -m = max(a) +m = a_[-1]