intuitive bisect solution
Intuitionuse binary search to sum up the elements that are not equal to the current - you know bisect will give you right half elements are greater than current
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
use binary search to sum up the elements that are not equal to the current - you know bisect will give you right half elements are greater than current and left are less than, so you can leverage this

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def minOperations(self, nums: List[int], queries: List[int]) -> List[int]:
        nums.sort()
        res = []
        p = list(itertools.accumulate(nums))
        n = len(nums)
        for q in queries:
            l = bisect_left(nums, q)
            r = bisect_right(nums, q)
            now = 0
            if l > 0:
                high = q * l
                now += (high - p[l - 1])
            if r < n:
                low = q * (n - r)
                if r <= 0:
                    high = p[-1]
                else:
                    high = p[-1] - p[r - 1]
                now += (high - low)
            res.append(now)
        return res


```
['Python3']