Problem 3284 · Medium

Sum of Consecutive Subarrays

Keep two running runs, one rising by one and one falling by one; each position extends them and adds their sums.

Open the interactive visualisation