JUST USE MAP AND CHECK IF OVERLAP || C++
```\nint maximizeGreatness(vector& nums) {\n        \n        map mp;\n        \n        for(auto &it: nums){\n            mp[it]++;\n        }\n        \n     
```\nint maximizeGreatness(vector<int>& nums) {\n        \n        map<int,int> mp;\n        \n        for(auto &it: nums){\n            mp[it]++;\n        }\n        \n        int j=0, placed=0,great=0;\n        \n        for(auto &it: mp){\n            if(j==0){\n                placed= it.second;\n            }\n            else{\n                great+= min(placed,it.second);\n                if(it.second>placed){\n                    placed=it.second;\n                }\n            }\n            j++;\n        }\n       \n        return great;\n    }
['C', 'C++']