Simple brute force
\nclass Solution {\npublic:\n    int maximumSum(vector<int>& nums) {\n        sort(nums.begin(), nums.end());\n        map<int, vector<int>>mp;\n        for(int
```\nclass Solution {\npublic:\n    int maximumSum(vector<int>& nums) {\n        sort(nums.begin(), nums.end());\n        map<int, vector<int>>mp;\n        for(int i=0; i<nums.size(); i++){\n            string str = to_string(nums[i]);\n            int x = 0;\n            for(int j=0; j<str.length(); j++){\n                x+=str[j]-\'0\';\n            }\n            mp[x].push_back(nums[i]);\n        }\n        int ans = INT_MIN;\n        for(auto it=mp.begin(); it!=mp.end(); it++){\n            int sum=0;\n            if((it->second).size()>1)\n            {\n                for(int i=0; i<(it->second).size()-1; i++)\n                    sum = max(sum, (it->second)[i]+(it->second)[i+1]);\n                ans = max(sum, ans);\n            }\n        }\n        return ans==INT_MIN?-1:ans;\n    }\n};\n```
['C++']