Positive Cumulative Sum

Easy

The cumulative sum of an array at index i is defined as the sum of all elements of the array from index 0 to index i.

Examples
Initial Array: [1, -2, 3, 4, -6]
Cumulative Sum: [1, -1, 2, 6, 0]
Initial Array: [1, -1, -1, -1, 1]
Cumulative Sum: [1, 0, -1, -2, -1]
Initial Array: [1, 3, 5, 7]
Cumulative Sum: [1, 4, 9, 16]

The positive cumulative sum of an array is a list of only those cumulative sums which are positive.

Examples
Initial Array: [1, -2, 3, 4, -6]
Cumulative Sum: [1, -1, 2, 6, 0]
Positive Cumulative Sum: [1, 2, 6]
Initial Array: [1, -1, -1, -1, 1]
Cumulative Sum: [1, 0, -1, -2, -1]
Positive Cumulative Sum: [1]
Initial Array: [1, 3, 5, 7]
Cumulative Sum: [1, 4, 9, 16]
Positive Cumulative Sum: [1, 4, 9, 16]

Given an array, return its positive cumulative sum.

Testing

Input Format

The first line contains 'T' denoting the no. of test cases.

Next T lines each contain a number 'n' denoting the number of elements, followed by n space-separated numbers denoting the array elements.

Output Format

T lines each contain all the positive cumulative sum for that test case.

Sample Input

3
5 1 -2 3 4 -6
5 1 -1 -1 -1 1
4 1 3 5 7

Expected Output

1 2 6
1
1 4 9 16

Constraints

0 <= T <= 1000

1 <= N <= 10000

-104 <= array element <= 104

Editorial Link: Editorial