N=int(eval(input()))

S=[int(eval(input())) for i in range(N)]

T=sorted(S,reverse=True)



for j in range(N):

  if S[j]!=T[0]:

    print((T[0]))

  else:

    print((T[1]))



  

n=int(eval(input()))

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

t=max(a)

s=a.index(t)

a.pop(s)

u=max(a)

for i in range(n):

  if i==s:

    print(u)

  else:

    print(t)





N = int(eval(input()))
S = [int(eval(input())) for i in range(N)]
T = sorted(S, reverse=True)
for j in range(N):
    if S[j] != T[0]:
        print((T[0]))
    else:
        print((T[1]))

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

-N = int(eval(input())) -S = [int(eval(input())) for i in range(N)] -T = sorted(S, reverse=True) -for j in range(N): -    if S[j] != T[0]: -        print((T[0])) +n = int(eval(input())) +a = [int(eval(input())) for i in range(n)] +t = max(a) +s = a.index(t) +a.pop(s) +u = max(a) +for i in range(n): +    if i == s: +        print(u) -        print((T[1])) +        print(t)