javascript + typescript solution 
```
function maximizeGreatness(nums: number[]): number {
    let sortedNums: number[] = nums.sort((a, b) => a - b);
    
    let right: number = 0;
    let res: number = 0;

    for(let i: number = 0; i < sortedNums.length; i++){
        while(right < sortedNums.length 
        && sortedNums[i][0] >= sortedNums[right][0]) right++;

       if(right !== sortedNums.length){
            right++
            res++
        }
    }

    return res
};

```
['Array', 'Two Pointers', 'Greedy', 'Sorting', 'TypeScript', 'Python3', 'JavaScript']