n = int(eval(input()))

a = [0]*n

for i in range(n):

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



b = [0]*n

c = [0]*n

b[0] = a[0]

c[n-1] = a[n-1]

for i in range(1,n):

    b[i]=max(b[i-1],a[i])

    c[n-1-i]=max(c[n-i],a[n-1-i])



for i in range(n):

    if i==0:

        print((c[1]))

    elif i==n-1:

        print((b[n-2]))

    else:

        print((max(b[i-1],c[i+1])))

n = int(eval(input()))

a = [0]*n

for i in range(n):

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

b = a[:]

b.sort()

for i in range(n):

    if a[i]==b[n-1]:

        print((b[n-2]))

    else:

        print((b[n-1]))

n = int(eval(input()))
a = [0] * n
for i in range(n):
    a[i] = int(eval(input()))
b = [0] * n
c = [0] * n
b[0] = a[0]
c[n - 1] = a[n - 1]
for i in range(1, n):
    b[i] = max(b[i - 1], a[i])
    c[n - 1 - i] = max(c[n - i], a[n - 1 - i])
for i in range(n):
    if i == 0:
        print((c[1]))
    elif i == n - 1:
        print((b[n - 2]))
    else:
        print((max(b[i - 1], c[i + 1])))

n = int(eval(input()))
a = [0] * n
for i in range(n):
    a[i] = int(eval(input()))
b = a[:]
b.sort()
for i in range(n):
    if a[i] == b[n - 1]:
        print((b[n - 2]))
    else:
        print((b[n - 1]))

-b = [0] * n -c = [0] * n -b[0] = a[0] -c[n - 1] = a[n - 1] -for i in range(1, n): -    b[i] = max(b[i - 1], a[i]) -    c[n - 1 - i] = max(c[n - i], a[n - 1 - i]) +b = a[:] +b.sort() -    if i == 0: -        print((c[1])) -    elif i == n - 1: +    if a[i] == b[n - 1]: -        print((max(b[i - 1], c[i + 1]))) +        print((b[n - 1]))