2 Pointerz || JAVA
Code\n\nclass Solution {\n    public int maximizeGreatness(int[] nums) {\n        int n = nums.length;\n        if(n == 1) return 0;\n        Arrays.sort(nums);
# Code\n```\nclass Solution {\n    public int maximizeGreatness(int[] nums) {\n        int n = nums.length;\n        if(n == 1) return 0;\n        Arrays.sort(nums);\n        int i=0;\n        int j=1;\n        \n        int ans =0;\n        \n        while(j < n){\n            if(nums[j] > nums[i]){\n                ans++;\n                i++;\n            }\n            j++;\n        }\n        \n        return ans;\n    }\n}\n```
['Java']