The base building block: cumulative sums.
Carry a running total, writing it at each index. This precomputation is what makes any range-sum query O(1) later: sum(i..j) becomes prefix[j] − prefix[i−1]. Doing it in place mutates the input to O(1) extra space; keep a separate output array if the caller still needs the originals. Trivial on its own, but it's the foundation the harder prefix-sum problems build on — the difference of two cumulative sums is the whole trick.
Foundation for range queries and 'sum so far' problems.
Time O(n) · Space O(1) (in place)