N = int(eval(input()))

a = list()

tmp = [0, 0]



for _ in range(N):

    ai = int(eval(input()))

    a.append(ai)

    if ai > tmp[1]:

        tmp[1] = ai

    elif ai > tmp[0]:

        tmp[0] = ai



m = tmp[1]



for ai in a:

    ans = m

    if ai == m:

        ans = tmp[0]

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

maximums = [0, 0]

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

maximums = sorted(nums, reverse=True)[:2]

for num in nums:

    if num == maximums[0]:

        print((maximums[1]))

    else:

        print((maximums[0]))
N = int(eval(input()))
a = list()
tmp = [0, 0]
for _ in range(N):
    ai = int(eval(input()))
    a.append(ai)
    if ai > tmp[1]:
        tmp[1] = ai
    elif ai > tmp[0]:
        tmp[0] = ai
m = tmp[1]
for ai in a:
    ans = m
    if ai == m:
        ans = tmp[0]
    print(ans)

n = int(eval(input()))
maximums = [0, 0]
nums = [int(eval(input())) for _ in range(n)]
maximums = sorted(nums, reverse=True)[:2]
for num in nums:
    if num == maximums[0]:
        print((maximums[1]))
    else:
        print((maximums[0]))

-N = int(eval(input())) -a = list() -tmp = [0, 0] -for _ in range(N): -    ai = int(eval(input())) -    a.append(ai) -    if ai > tmp[1]: -        tmp[1] = ai -    elif ai > tmp[0]: -        tmp[0] = ai -m = tmp[1] -for ai in a: -    ans = m -    if ai == m: -        ans = tmp[0] -    print(ans) +n = int(eval(input())) +maximums = [0, 0] +nums = [int(eval(input())) for _ in range(n)] +maximums = sorted(nums, reverse=True)[:2] +for num in nums: +    if num == maximums[0]: +        print((maximums[1])) +    else: +        print((maximums[0]))