Can someone please help me with this problem

Problem
Solution
i understood the first half of this problem where we are greedily binary searching for the index corresponding to the last value from which we can reach ith index;
but in the second half i did not understand how idx array and the prefix sums are working
Thanks in advance