PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#PS0000116. Dãy tổng tích lũy (Running Sum of 1d Array)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Dãy tổng tích lũy (Running Sum of 1d Array)

Running Sum of 1d Array

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

An array of nn integers a0,a1,…,an−1a_0,a_1,\ldots,a_{n-1} is indexed from 0. At index ii, the running sum bib_i includes every element from the beginning of the array through aia_i. Find the entire array b0,b1,…,bn−1b_0,b_1,\ldots,b_{n-1} in order.

Input

The first line contains integer nn.

The second line contains nn integers a0,…,an−1a_0,\ldots,a_{n-1}.

Output

Print nn space-separated integers b0,…,bn−1b_0,\ldots,b_{n-1} on one line.

Subtasks

  • Subtask 1 (20 points): 1≤n≤201\le n\le 20; −106≤ai≤106-10^6\le a_i\le 10^6; 0≤i<n0\le i<n.
  • Subtask 2 (30 points): 1≤n≤10001\le n\le 1000; −106≤ai≤106-10^6\le a_i\le 10^6; 0≤i<n0\le i<n; ai=a0a_i=a_0 (0≤i<n0\le i<n).
  • Subtask 3 (50 points): 1≤n≤10001\le n\le 1000; −106≤ai≤106-10^6\le a_i\le 10^6; 0≤i<n0\le i<n.

Example 1

Input

4
1 2 3 4

Output

1 3 6 10

Explanation

The successive sums are 11, 1+2=31+2=3, 1+2+3=61+2+3=6, and 1+2+3+4=101+2+3+4=10.

Example 2

Input

5
1 1 1 1 1

Output

1 2 3 4 5

Explanation

Every value equals 1, so the sum of the first i+1i+1 elements is i+1i+1. The five results are 1, 2, 3, 4, 5.

Example 3

Input

5
3 1 2 10 1

Output

3 4 6 16 17

Explanation

Start with 3; adding 1, 2, 10, and 1 successively yields 4, 6, 16, and 17.