Surprisingly easy solution
Code\n\npublic class Solution \n{\n    public long MaximumValueSum(int[] nums, int k, int[][] edges) \n    {\n        long result = 0;\n\n        foreach (long 
# Code\n```\npublic class Solution \n{\n    public long MaximumValueSum(int[] nums, int k, int[][] edges) \n    {\n        long result = 0;\n\n        foreach (long num in nums)\n            result += num;\n        \n        var queue = new PriorityQueue<int, int>();\n        \n        foreach (var num in nums)\n        {\n            var xor = num ^ k;\n            var diff = xor - num;\n            \n            queue.Enqueue(diff, -diff);\n        }\n        \n        while (queue.Count >= 2)\n        {\n            var value = queue.Dequeue() + queue.Dequeue();\n            \n            if (value > 0)\n                result += value;\n        }\n        \n        return result;\n    }\n}\n```
['C#']