[Java/Python 3] Sort then 2 pointers.
Sort then start from index 0 to check how many pairs of nums[ans] < nums[j] (num in the code) we can have.\n\njava\n    public int maximizeGreatness(int[] nums)
Sort then start from index `0` to check how many pairs of `nums[ans] < nums[j] (num in the code)` we can have.\n\n```java\n    public int maximizeGreatness(int[] nums) {\n        Arrays.sort(nums);\n        int ans = 0;\n        for (int num : nums) {\n            if (nums[ans] < num) {\n                ++ans;\n            }\n        }\n        return ans;\n    }\n```\n\n```python\n    def maximizeGreatness(self, nums: List[int]) -> int:\n        nums.sort()\n        ans = 0\n        for num in nums:\n            if nums[ans] < num:\n                ans += 1\n        return ans\n```\n\n**Analysis:**\n\nTime: `O(nlogn)`, space: `O(sorting space)`, where `n = nums.length`.
['Java', 'Python3']