C++ sort
```cpp []
class Solution {
public:
    int maximizeGreatness(vector<int>& nums) {
        int ans = 0;
        sort(nums.begin(), nums.end());
        int l = 0;
        for (int i = 0; l < nums.size() && i < nums.size(); ++i){
            while (l < nums.size() && nums[l] == nums[i]) ++l;
            ans += l < nums.size();
            ++l;
        }
        return ans;
    }
};
```
['C++']