O(NlogN) solution!! very easy!!
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int maximizeGreatness(vector<int>& nums) {\n        sort(nums.begin(),nums.end());\n        int i=0;\n        int n=nums.size();\n        int ans=0;\n\n        for(int k=i+1;k<n;k++){\n            if(nums[i]<nums[k]){\n                ans++;\n                i++;\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']