C# max heap and sorting
\npublic class Solution {\n    public long KSum(int[] nums, int k) {\n        long sum = 0;\n        foreach(int n in nums)\n            if(n > 0) sum += n;\n  
```\npublic class Solution {\n    public long KSum(int[] nums, int k) {\n        long sum = 0;\n        foreach(int n in nums)\n            if(n > 0) sum += n;\n        Array.Sort(nums, (a,b) => { return Math.Abs(a)-Math.Abs(b); } );\n        PriorityQueue<(long, long), long> pq = new();\n        pq.Enqueue((sum-Math.Abs(nums[0]),0), sum-Math.Abs(nums[0]*-1));\n        while(--k > 0){\n            (long Sum, long Idx) c = pq.Dequeue();\n            if(c.Idx+1 <= nums.Length-1){\n                long nextIdx = c.Idx+1, nextSum = c.Sum-Math.Abs(nums[nextIdx]);\n                pq.Enqueue((nextSum, nextIdx), nextSum*-1);\n                pq.Enqueue((nextSum+Math.Abs(nums[c.Idx]), nextIdx), (nextSum+Math.Abs(nums[c.Idx]))*-1);\n            }\n            sum = c.Sum;\n        }\n        return sum;\n    }\n}\n```
['Heap (Priority Queue)', 'C#']