Prefix Sum ArrayEasy

Prefix Sum Array

EasyPractice library · +10 XPprefix sumsrange queries

Given a list of N integers, compute and print the prefix sum array. The prefix sum array P of an array A is defined such that P[i] is the sum of all elements in A from index 0 to i (inclusive).

For example, if the input array A is [1, 2, 3, 4], its prefix sum array P would be [1, 3, 6, 10].

Input

The first line contains an integer N (the number of elements). The second line contains N space-separated integers, the elements of the array.

Output

Print N space-separated integers, the elements of the prefix sum array.

Constraints

1 <= N <= 1000 -1000 <= A[i] <= 1000

Time limit 1 s (native code; slower languages get more)Memory 256 MB13 hidden tests

Example 1

Input
4
1 2 3 4
Output
1 3 6 10

The prefix sums are 1, 1+2=3, 3+3=6, 6+4=10.

Example 2

Input
5
10 -5 20 3 0
Output
10 5 25 28 28

The prefix sums are 10, 10-5=5, 5+20=25, 25+3=28, 28+0=28.

Hints