n=int(eval(input()))

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

a_max=max(a)

x=a.index(a_max)

a_sort=sorted(a)

y=a_sort[-2]

for i in range(n):

  if i==x:

    print(y)

  else:

    print(a_max)
n=int(eval(input()))

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



s=max(a)

t=a.index(s)



for i in range(n):

  if i==t:

    del a[t]

    print((max(a)))

  else:

    print(s)
n = int(eval(input()))
a = [int(eval(input())) for _ in range(n)]
a_max = max(a)
x = a.index(a_max)
a_sort = sorted(a)
y = a_sort[-2]
for i in range(n):
    if i == x:
        print(y)
    else:
        print(a_max)

n = int(eval(input()))
a = [int(eval(input())) for i in range(n)]
s = max(a)
t = a.index(s)
for i in range(n):
    if i == t:
        del a[t]
        print((max(a)))
    else:
        print(s)

-a = [int(eval(input())) for _ in range(n)] -a_max = max(a) -x = a.index(a_max) -a_sort = sorted(a) -y = a_sort[-2] +a = [int(eval(input())) for i in range(n)] +s = max(a) +t = a.index(s) -    if i == x: -        print(y) +    if i == t: +        del a[t] +        print((max(a))) -        print(a_max) +        print(s)