#C14332. Cumulative Sum
Cumulative Sum
Cumulative Sum
Given a list of integers, your task is to compute the cumulative sum of the list. For each index \(i\), the \(i\)-th element of the result is given by:
\(S_i = \sum_{j=0}^{i} a_j\)
where \(a_j\) is the \(j\)-th element of the input list. For example, if the input is [1, 2, 3, 4]
, the cumulative sum is [1, 3, 6, 10]
.
The input will be given via standard input and the output should be printed to standard output.
inputFormat
The first line contains a single integer \(n\) representing the number of elements in the list. The second line contains \(n\) space-separated integers representing the elements of the list.
outputFormat
Output a single line containing \(n\) space-separated integers, where the \(i\)-th integer is the cumulative sum of the first \(i+1\) elements of the input list.
## sample4
1 2 3 4
1 3 6 10