C# Binary Search
csharp\npublic class Solution\n{\n    public IList<long> MinOperations(int[] nums, int[] queries)\n    {\n        Array.Sort(nums);\n\n        var sum = 0L;\n  
```csharp\npublic class Solution\n{\n    public IList<long> MinOperations(int[] nums, int[] queries)\n    {\n        Array.Sort(nums);\n\n        var sum = 0L;\n        var prefix = Array.ConvertAll(nums, num => sum += num);\n\n        return Array.ConvertAll(queries, query =>\n        {\n            var index = Array.BinarySearch(nums, query);\n            var upperBound = Math.Abs(index + 1);\n\n            var ops = prefix[^1];\n            ops += query * ( 2L * upperBound - nums.Length);\n            ops -= 2L * prefix.ElementAtOrDefault(upperBound - 1);\n            return ops;\n        });\n    }\n}\n```
['Binary Search', 'C#']