Easy java Solution
\n\n# Code\n\nclass Solution {\n    public long maximumHappinessSum(int[] hap, int k) {\n        Arrays.sort(hap);\n        long ans=hap[hap.length-1];\n       
\n\n# Code\n```\nclass Solution {\n    public long maximumHappinessSum(int[] hap, int k) {\n        Arrays.sort(hap);\n        long ans=hap[hap.length-1];\n        k--;\n        int count=1;\n        for(int i=hap.length-2;i>=0;i--){\n            if(k>0){\n                if(hap[i]-count<=0){\n                    ans+=0;\n                    break;\n                }\n                else\n                ans+=hap[i]-count;\n                count++;\n                k--;\n            }\n        }\n        return ans;\n    }\n}\n```
['Array', 'Sorting', 'Java']