The difference array is the prefix sum run backwards, and it makes range updates cheap the way prefix sums make range queries cheap. To add v to every element in [i..j], you touch just two cells of the difference array: d[i] += v and d[j+1] −= v. Apply as many range updates as you like — each is O(1) — then a single prefix-sum pass reconstructs the final array. A correct naive updater walks the whole range every time (O(range) each); the difference array defers all of it to one closing integration. It is the discrete derivative, and the imos method of competitive programming.
A range update on a zero array. The demo marks two cells and integrates to read the updated value: live demo
“Adding to a range means writing every cell in it.” — the difference array marks the two endpoints and defers the work to one final integration; a hundred range updates cost two cells each. cited
Two marks stand in for a whole range; the sum at the end makes them real. The discrete derivative, deferred and then integrated. difference array
On the canonical compiler, adding +2 across positions 1..3 via marks d[1]+=2, d[4]−=2 then integrating gives value 2 at position 2: