Sort + Prefix Sum +  Binary Search
```javascript []
var minOperations = function (nums, queries) {
  const sorted = nums.toSorted((a, b) => a - b);
  const n = sorted.length;

  // Build prefix sums
  const sums = [0];
  for (let i = 0; i < n; i++) sums.push(sums[i] + sorted[i]);

  // Find position using binary search
  const findPos = (target) => {
    let left = 0, right = n;
    while (left < right) {
      const mid = (left + right) >> 1;
      sorted[mid] < target ? left = mid + 1 : right = mid;
    }
    return left;
  };

  return queries.map(target => {
    const pos = findPos(target);
    return Number(BigInt(target * (2 * pos - n)) - BigInt(2 * sums[pos]) + BigInt(sums[n]));
  });
};
```
['Array', 'Binary Search', 'Sorting', 'Prefix Sum', 'JavaScript']