python3 Solution
\n\nclass Solution:\n    def minOperations(self, nums: List[int], queries: List[int]) -> List[int]:\n        nums.sort()\n        n=len(nums)\n        prefix=[0
\n```\nclass Solution:\n    def minOperations(self, nums: List[int], queries: List[int]) -> List[int]:\n        nums.sort()\n        n=len(nums)\n        prefix=[0]+list(accumulate(nums))\n        ans=[]\n        for x in queries:\n            i=bisect_left(nums,x)\n            ans.append(x*(2*i-n)+prefix[n]-2*prefix[i])\n\n        return ans    \n```
['Python', 'Python3']