brute force
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n\nint solve(map<int,int>&mp,int x){\n    vector<pair<int,int>>ans; //freq ,element storing \n    for(auto &i:mp){\n        ans.push_back({i.second,i.first});        \n    }\n\n    int res=0;\n    auto cmp=[](auto a,auto b){\n        if(a.first==b.first)return a.second>b.second;\n        return a.first>b.first;        \n    };\n    sort(ans.begin(),ans.end(),cmp);//costum sort\n     \n    for(int i=0;i<ans.size();i++){\n         \n        res+=(ans[i].first)*ans[i].second;\n        x-=1;//decrease x every times\n        if(x==0)break;\n    }\n    return res;\n}\n    vector<int> findXSum(vector<int>& nums, int k, int x) {\n        int n=nums.size();\n\n        vector<int>ans(n-k+1);\n         for(int i=0;i<n-k+1;i++){\n            map<int,int>mp;\n            //calculating freq\n            for(int j=i;j<k+i;j++){               \n                mp[nums[j]]++;\n            } \n            int f=solve(mp,x);\n            ans[i]=f;\n         }\n         return ans;\n    }\n};\n```
['Hash Table', 'Ordered Map', 'C++']