Imagine a D (two-dimensional) grid where is a cell. You fill the grid diagonal by diagonal (by length). For cell , you look at (one left) and (one down).
Their values bound where to search. The search range for each cell is small. Across a diagonal, ranges tile the space without much overlap. That's why the total is per diagonal, overall. Understanding this concept will help you solve more complex problems.