initialValue currentValue position elements final value
first calculation 0 1 1 [0, 1, 2, 3, 4] 1
second run 1 2 2 [0, 1, 2, 3, 4] 3
third round 3 3 3 [0, 1, 2, 3, 4] 6
fourth iteration 6 4 4 [0, 1, 2, 3, 4] 10
I'm interested in having 1, 3, 6, and 10 stored in an array per call instead of the total sum 10. Therefore, I need to capture the result from each operation individually.