Match Room parameter value list with a list of lenghts "Math.sum"

Thanks to a Python Script by @Martin_Bijsterbosch; at this topic:
I could create a list of matched rooms/elements.

But now I am still stuck in the point of matching the “Sum” vlaues correctly with the list of the rooms. I always get wrong results mapped with the wrong rooms.

Please find below:

This is what I want: