#ARC120A. [ARC120A] Max Add

[ARC120A] Max Add

Score : 400400 points

Problem Statement

For a sequence a=(a1,a2,a3,,ak)a = (a_1, a_2, a_3, \dots, a_k), let f(a)f(a) be the sum of its elements after the following is done:

  • For each i=1,2,3,,ki = 1, 2, 3, \dots, k, in this order, do the following operation: add the current maximum value of an element in aa to aia_i.

You are given a sequence of length NN: A=(A1,A2,A3,,AN)A = (A_1, A_2, A_3, \dots, A_N). For each integer kk between 11 and NN (inclusive), find f(a)f(a) when a=(A1,A2,A3,,Ak)a = (A_1, A_2, A_3, \dots, A_k).

Constraints

  • 1N2×1051 \le N \le 2 \times 10^5
  • 1Ai1071 \le A_i \le 10^7
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 A3A_3 \dots ANA_N

Output

Print NN lines. The kk-th line should contain f(a)f(a) when a=(A1,A2,A3,,Ak)a = (A_1, A_2, A_3, \dots, A_k).

3
1 2 3
2
8
19

For example, when a=(A1,A2,A3)a = (A_1, A_2, A_3), f(a)f(a) is computed as follows:

  • First, for i=1i = 1, add to a1a_1 the current maximum value of aa, which is 33, making a=(4,2,3)a = (4, 2, 3).
  • Next, for i=2i = 2, add to a2a_2 the current maximum value of aa, which is 44, making a=(4,6,3)a = (4, 6, 3).
  • Finally, for i=3i = 3, add to a3a_3 the current maximum value of aa, which is 66, making a=(4,6,9)a = (4, 6, 9).
  • f(a)f(a) is the sum of the elements of aa now, which is 1919.