c++ solution
\nclass Solution {\npublic:\n    int getLowerBound(vector<int>&nums, int value){\n        int size=nums.size();\n        int left=0,right=size-1,mid=0,index=siz
```\nclass Solution {\npublic:\n    int getLowerBound(vector<int>&nums, int value){\n        int size=nums.size();\n        int left=0,right=size-1,mid=0,index=size;\n        while(left<=right){\n            mid=(left+right)/2;\n            if(nums[mid]>value){\n                index=mid;\n                right=mid-1;\n            }\n            else{\n                left=mid+1;\n            }\n        }\n        return index;\n    }\n    vector<long long> minOperations(vector<int>& nums, vector<int>& queries) {\n        int n=nums.size();\n        sort(nums.begin(),nums.end());\n        vector<long long>prefix(n+1,0);\n        for(int i=0;i<n;i++){\n            prefix[i+1]=prefix[i]+nums[i];\n        }\n        vector<long long>ans;\n        for(auto &value:queries){\n            long long index=getLowerBound(nums,value);\n            long long leftSum = value*index - (prefix[index]-prefix[0]);\n            long long rightSum = (prefix.back()-prefix[index]) - value*(n-index);\n            ans.push_back(leftSum+rightSum);\n        }\n        return ans;\n    }\n};\n```
['C', 'C++']