Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Given that the sum is strictly increasing, the largest element in the target must be formed in the last step by adding the total sum in the previous step. Thus, we can simulate the process in a reversed way.
Subtract the largest with the rest of the array, and put the new element into the array. Repeat until all elements become one