Source: https://courses.cs.washington.edu/courses/cse142/12au/lectures/10-15/10-ch04-2-cumulativesum.pdf