Sort + Two Pointers
```javascript []
/**
 * @param {number[]} nums
 * @return {number}
 */
var maximizeGreatness = function (nums) {
  nums.sort((a, b) => a - b)

  let count = 0
  let j = 1

  for (let i = 0; i < nums.length; i++) {
    // Find the next element that satisfies nums[i] < nums[j]
    while (j < nums.length && nums[i] >= nums[j]) j++

    if (j < nums.length) {
      count += 1
      j += 1
    }
  }

  return count
};
```
['Array', 'Two Pointers', 'Greedy', 'Sorting', 'JavaScript']