You might start looking at the block-internal sum and then at the larger examples. Hey, noone said fast solutions are always simple - but the prefix sum is not too hard to understand… External Media

You solution will be even simpler than prefix sums, since you’re only computing the sum (you don’t need all the other (n-1) sums). This has been discussed on a previous thread: sum of all elements of a matrix