Precompute a running total once, and every range sum after that is a subtraction instead of a rescan. prefix[i] holds the sum of everything up to and including index i, so the sum of any range [left, right] is just prefix[right] - prefix[left-1] - one lookup, no matter how wide the range. The same idea runs in either direction: a forward pass answers "what's the total up to here", a backward pass answers "what's the total from here to the end".
Build the running total once in the constructor, then answer every query in O(1) by subtracting two prefix sums instead of rescanning the range each time.
The mirror image: nothing is precomputed for reuse, but each position's update implicitly covers everything from it to the end (or start) of the array, so a single accumulating pass in that direction reconstructs the total directly, without ever building a difference array.
When a position's answer depends on both sides of it, neither direction alone is enough - build the forward pass and the backward pass, then read one value from each. The pair of arrays turns a per-index rescan of the whole array into two lookups.