Easy sol^n
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    vector<long long> minOperations(vector<int>& nums, vector<int>& queries) {\n        sort(nums.begin(),nums.end());\n        vector<long long>ans;\n        vector<long long>sum(nums.size(),0);\n        sum[0]=nums[0];\n        for(int i=1;i<nums.size();i++)\n        {\n           sum[i]=sum[i-1]+nums[i];\n        }\n        for(int i=0;i<queries.size();i++)\n        {\n            int index=-1;\n            int s=0;\n            int e=nums.size()-1;\n            int mid=s+(e-s)/2;\n            while(s<=e)\n            {\n              if(nums[mid]==queries[i])\n               {\n                index=mid;\n                break;\n               }\n               else if(nums[mid]>queries[i])\n               {\n                 e=mid-1;\n               }\n               else\n               {\n                 index=mid;\n                 s=mid+1;\n               }\n               mid=s+(e-s)/2;\n            }\n            long long left=1;\n            long long right=1;\n                index++;\n                left=((long long)queries[i])*index;\n                right=((long long)queries[i])*(nums.size()-index);\n                index--;\n                if(index!=-1)\n                {\n                 left=left-sum[index];\n                 right=(sum[nums.size()-1]-sum[index])-right;\n                }\n                else\n                {\n                    left=0;\n                    right=sum[nums.size()-1]-right;\n                }\n                ans.push_back(left+right);\n        }  \n        return ans;\n    }\n};\n```
['Array', 'Binary Search', 'Sorting', 'Prefix Sum', 'C++']