




Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Let's note that we want to either decrease the sum of the array with a larger sum or increase the array's sum with the smaller sum.
You can maintain the largest increase or decrease you can make in a binary search tree and each time get the maximum one.