The contract does not state whether totals should be returned from the middle outward or from the ends inward. I cannot guess the intended behavior.

Please provide the complete specification for the output order.