Java code (Using sorting method)
\n# Code\n\nclass Solution {\n    public int maximizeGreatness(int[] nums) {\n        Arrays.sort(nums);\n        int p1 = 0;\n        int p2 = 1;\n        int 
\n# Code\n```\nclass Solution {\n    public int maximizeGreatness(int[] nums) {\n        Arrays.sort(nums);\n        int p1 = 0;\n        int p2 = 1;\n        int count = 0;\n        while(p2 < nums.length){\n            if(nums[p2] > nums[p1]){\n                count++;\n                p1++;\n                p2++;\n            }\n            if(p2 < nums.length && nums[p1] == nums[p2]){\n                p2++;\n            }\n        }\n        return count;\n    }\n}\n```
['Java']