Contribution Counting
Suppose we need the sum of the sums of every nonempty contiguous subarray. Enumerating each subarray repeats the same additions.
Suppose we need the sum of the sums of every nonempty contiguous subarray. Enumerating each subarray repeats the same additions.