import sys

input = sys.stdin.readline



import numpy as np



N = int(eval(input()))

A = np.array([int(eval(input())) for _ in range(N)])



from_left = np.maximum.accumulate(A)

from_right = np.maximum.accumulate(A[::-1])[::-1]



from_left, from_right



from_left = [0] + from_left.tolist()[:-1]

from_right = from_right[1:].tolist() + [0]



for x,y in zip(from_left, from_right):

    print((x if x > y else y))

N = int(eval(input()))

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

B = sorted(A)[::-1]

a1 = B[0]

a2 = B[1]



if a1==a2:

  for n in range(N):

    print(a1)

else:

  for n in range(N):

    if A[n]==a1:

      print(a2)

    else:

      print(a1)
import sys

input = sys.stdin.readline
import numpy as np

N = int(eval(input()))
A = np.array([int(eval(input())) for _ in range(N)])
from_left = np.maximum.accumulate(A)
from_right = np.maximum.accumulate(A[::-1])[::-1]
from_left, from_right
from_left = [0] + from_left.tolist()[:-1]
from_right = from_right[1:].tolist() + [0]
for x, y in zip(from_left, from_right):
    print((x if x > y else y))

N = int(eval(input()))
A = [int(eval(input())) for n in range(N)]
B = sorted(A)[::-1]
a1 = B[0]
a2 = B[1]
if a1 == a2:
    for n in range(N):
        print(a1)
else:
    for n in range(N):
        if A[n] == a1:
            print(a2)
        else:
            print(a1)

-import sys - -input = sys.stdin.readline -import numpy as np - -A = np.array([int(eval(input())) for _ in range(N)]) -from_left = np.maximum.accumulate(A) -from_right = np.maximum.accumulate(A[::-1])[::-1] -from_left, from_right -from_left = [0] + from_left.tolist()[:-1] -from_right = from_right[1:].tolist() + [0] -for x, y in zip(from_left, from_right): -    print((x if x > y else y)) +A = [int(eval(input())) for n in range(N)] +B = sorted(A)[::-1] +a1 = B[0] +a2 = B[1] +if a1 == a2: +    for n in range(N): +        print(a1) +else: +    for n in range(N): +        if A[n] == a1: +            print(a2) +        else: +            print(a1)