c++ solution
\nclass Solution {\npublic:\n    long long kSum(vector<int>& nums, int k) {\n        int n=nums.size();\n        vector<long long>ans;\n        priority_queue<p
```\nclass Solution {\npublic:\n    long long kSum(vector<int>& nums, int k) {\n        int n=nums.size();\n        vector<long long>ans;\n        priority_queue<pair<long long,long long>>pq;\n        long long sum=0;\n        for(int i=0;i<n;i++)\n        {\n            if(nums[i]>0)\n            {\n                sum+=nums[i];\n            }\n            nums[i]=abs(nums[i]);\n        }\n        sort(nums.begin(),nums.end());\n        pq.push({sum-nums[0],0});\n        ans.push_back(sum);\n        while(ans.size()<k)\n        {\n            auto [val,index]=pq.top();\n            pq.pop();\n            ans.push_back(val);\n            if(index+1<n)\n            {\n                pq.push({val+nums[index]-nums[index+1],index+1});\n                pq.push({val-nums[index+1],index+1});\n            }\n        }\n        return ans[k-1];\n    }\n};\n```
['C', 'Heap (Priority Queue)', 'C++']