N = int(eval(input()))

A = []

for n in range(N):

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

B = [0 for n in range(N)]

B[0] = A[0]

for n in range(N-1):

    B[n+1] = max(B[n], A[n + 1])

C = [0 for n in range(N)]

C[-1] = A[-1]

for n in range(N - 1):

    C[-n-2] = max(C[-n-1], A[-n - 2])

for n in range(N):

    if n == 0:

        print((C[1]))

    elif n == N - 1:

        print((B[N - 2]))

    else:

        print((max(B[n-1], C[n+1])))

n = int(eval(input()))

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



l = 0

L = [l]

for a in A:

    l = max(l, a)

    L.append(l)



r = 0

R = [r]

for a in A[::-1]:

    r = max(r, a)

    R.append(r)

R.reverse()



for i in range(n):

    print((max(L[i], R[i+1])))

N = int(eval(input()))
A = []
for n in range(N):
    A.append(int(eval(input())))
B = [0 for n in range(N)]
B[0] = A[0]
for n in range(N - 1):
    B[n + 1] = max(B[n], A[n + 1])
C = [0 for n in range(N)]
C[-1] = A[-1]
for n in range(N - 1):
    C[-n - 2] = max(C[-n - 1], A[-n - 2])
for n in range(N):
    if n == 0:
        print((C[1]))
    elif n == N - 1:
        print((B[N - 2]))
    else:
        print((max(B[n - 1], C[n + 1])))

n = int(eval(input()))
A = [int(eval(input())) for i in range(n)]
l = 0
L = [l]
for a in A:
    l = max(l, a)
    L.append(l)
r = 0
R = [r]
for a in A[::-1]:
    r = max(r, a)
    R.append(r)
R.reverse()
for i in range(n):
    print((max(L[i], R[i + 1])))

-N = int(eval(input())) -A = [] -for n in range(N): -    A.append(int(eval(input()))) -B = [0 for n in range(N)] -B[0] = A[0] -for n in range(N - 1): -    B[n + 1] = max(B[n], A[n + 1]) -C = [0 for n in range(N)] -C[-1] = A[-1] -for n in range(N - 1): -    C[-n - 2] = max(C[-n - 1], A[-n - 2]) -for n in range(N): -    if n == 0: -        print((C[1])) -    elif n == N - 1: -        print((B[N - 2])) -    else: -        print((max(B[n - 1], C[n + 1]))) +n = int(eval(input())) +A = [int(eval(input())) for i in range(n)] +l = 0 +L = [l] +for a in A: +    l = max(l, a) +    L.append(l) +r = 0 +R = [r] +for a in A[::-1]: +    r = max(r, a) +    R.append(r) +R.reverse() +for i in range(n): +    print((max(L[i], R[i + 1])))