Core Idea
Think of each operation as changing only the points where a range starts and stops. Store those changes in a difference array instead of touching every element in the range.
Algorithm
For an update (l, r, x), add x at l and subtract x at r + 1 when that index exists. A final prefix sum over the difference array reconstructs the array after all updates.
Common Mistakes
Use 64-bit integers because many updates can stack on the same position. Be careful with the r + 1 boundary, especially when r = n.