#C12944. Running Sum of a Sequence
Running Sum of a Sequence
Running Sum of a Sequence
Given a sequence of integers, compute the running sum of the sequence. For each index \(i\), the running sum is defined as:
\[ S_i = \sum_{j=1}^{i} a_j \]
The sequence may include negative numbers and can have varying lengths, including an empty sequence. Your task is to print the running sum values separated by a space.
Example:
Input: 5 1 2 3 4 5</p>Output: 1 3 6 10 15
inputFormat
The input is read from standard input (stdin). The first line contains a single integer \(n\) which represents the number of elements in the sequence. The next line contains \(n\) integers separated by spaces. If \(n = 0\), then the sequence is empty.
outputFormat
Output the running sum of the sequence to standard output (stdout) as \(n\) integers separated by a space. If the sequence is empty, output nothing.
## sample5
1 2 3 4 5
1 3 6 10 15