Easy Cpp Solution
\n# Code\n\nclass Solution {\npublic:\n    long long maximumHappinessSum(vector<int>& arr, int k) {\n        long long sum= 0 , diff=0 ; \n        sort(arr.begi
\n# Code\n```\nclass Solution {\npublic:\n    long long maximumHappinessSum(vector<int>& arr, int k) {\n        long long sum= 0 , diff=0 ; \n        sort(arr.begin() , arr.end(),greater<int>());\n        int n = arr.size();\n       for(int i=0 ; i<k ; i++)\n       {\n           if(arr[i] > diff)\n           {\n               sum += arr[i] - diff;\n           }\n           diff++;\n       }\n        return sum;\n    }\n};\n```
['C++']