We have a problem about how to quickly calculate the sums on the interval l...r in a static array a in less than O(n) asymptotics.

Let's divide the array a into k blocks of the same size and first calculate the sum of elements for each of them.

Now, when answering the request, we can go through the elements of the array a and add them to the result, also if one of the blocks lies inside the segment, then we can add its sum to the result and skip the elements of this block.

The maximum number of operations per query with this algorithm is n / k + k, so the optimal k is equal to the square root of n.