Javascript On^2

```javascript []
/**
 * @param {number[]} nums
 * @return {number}
 */
var minimumPairRemoval = function(nums) {
    let ans = 0

    while (!isNonDecreasing(nums)) {
        const i = findMinSumPairIndex(nums)
        const merged = nums[i] + nums[i+1]

        nums.splice(i, 2, merged)
        ans += 1
    }

    console.log("ans: ", ans)
    return ans
};

function isNonDecreasing(arr) {
    for (let i = 1; i < arr.length; i++) {
        if (arr[i] < arr[i - 1]) return false;
    }
    return true;
}

function findMinSumPairIndex(arr) {
    let minSum = Infinity;
    let index = -1;

    for (let i = 0; i < arr.length - 1; i++) {
        let sum = arr[i] + arr[i + 1];
        if (sum < minSum) {
            minSum = sum;
            index = i;
        }
    }

    return index; // index of the leftmost min-sum pair
}
```
['JavaScript']