#K56102. Cumulative Sum Calculation

    ID: 30124 Type: Default 1000ms 256MiB

Cumulative Sum Calculation

Cumulative Sum Calculation

Given an array of non-negative integers, your task is to compute a new array in which the i-th element is the cumulative sum of the first i numbers of the original array. In other words, if the input array is \(a_1, a_2, \ldots, a_n\), you need to output an array \(b_1, b_2, \ldots, b_n\) such that:

\[ b_i = \sum_{j=1}^{i} a_j, \quad \text{for } 1 \le i \le n \]

If the array is empty, simply output an empty result.

inputFormat

The input is given via standard input (stdin) and is formatted as follows:

  • The first line contains a single integer \(n\) representing the number of elements in the array.
  • The second line contains \(n\) space-separated non-negative integers.

If \(n = 0\), then there will be no numbers in the second line.

outputFormat

Output the cumulative sum array as \(n\) space-separated integers on a single line via standard output (stdout). If the array is empty, output nothing.

## sample
4
1 2 3 4
1 3 6 10