Java 100%
ApproachWe use helper functions to check whether the array is sorted and to get the index of the minimum pair.While the array is not sorted, replace the min pai
# Approach
We use helper functions to check whether the array is sorted and to get the index of the minimum pair.

While the array is not sorted, replace the min pair with their sum and increment the counter.

When the array is sorted, return the counter.

# Complexity
- Time complexity: $O(N^2)$
- Space complexity: $O(N)$

# Code
```java []
class Solution
{
    public int minimumPairRemoval(int[] nums)
    {
        ArrayList<Integer> a = new ArrayList<>(nums.length);

        for(int x : nums)
            a.add(x);

        int c = 0;
        int minP;

        while(!isSorted(a))
        {
            c++;
            minP = getMin(a);

            a.set(minP, a.get(minP)+a.get(minP+1));
            a.remove(minP+1);
        }

        return c;
    }

    private boolean isSorted(ArrayList<Integer> a)
    {
        for(int p=a.get(0),i=1, l=a.size(); i<l; p=a.get(i++))
            if(a.get(i)<p)
                return false;

        return true;
    }

    private int getMin(ArrayList<Integer> a)
    {
        int minP = 0;
        int minV = a.get(0) + a.get(1);

        for(int i=1, l=a.size(); i<l-1; i++)
            if(a.get(i) + a.get(i+1)<minV)
            {
                minV = a.get(i) + a.get(i+1);
                minP = i;
            }

        return minP;
    }
}
```
['Java']