EASIEST SOLUTION EVER JUST BINARY  SEARCH
Intuition\nTRIPPY\'S CODING TECHNIQUE \nHERE I AM PRESENTING JAVA CODE USE VECTOR IN PLACE OF ARRAY FOR C++\n\n# Approach\nSS APROACH\nJUST SMILE AND SOLVE\n\n#
# Intuition\nTRIPPY\'S CODING TECHNIQUE \nHERE I AM PRESENTING JAVA CODE USE VECTOR IN PLACE OF ARRAY FOR C++\n\n# Approach\nSS APROACH\nJUST SMILE AND SOLVE\n\n# Complexity\nNOTHING COMPLEX\n\n# PLEASE UPVOTE\nPLEASE UPVOTE IF I HELPED YOU \nTHANK YOU\nLOVE FOR YOU BY TRIPPY \n\n# Code\n```\nclass Solution {\n    public List<Long> minOperations(int[] nums, int[] queries) {\n        \n        int n = nums.length;\n        int m = queries.length;\n        \n        List<Long> list = new ArrayList<>();\n        \n        Arrays.sort(nums);\n        long[] arr1 = new long[n];\n        long[] arr2 = new long[n];\n        \n        arr1[0] = nums[0];\n        for(int i=1; i<n; i++){\n            arr1[i] = arr1[i-1]+nums[i];\n        }\n        \n        arr2[n-1] = nums[n-1];\n        for(int i=n-2; i>=0; i--){\n            arr2[i] = arr2[i+1]+nums[i];\n        }\n        \n        for(int i : queries){\n            long sum = 0l;\n            int s=0; int e = n-1;\n            \n            while(s<=e){\n                int mid = s + (e-s)/2;\n                \n                if(nums[mid] <= i){ s = mid+1; }\n                else{ e = mid-1; }\n            }\n            \n            sum += s>0 ?((long)i * (long)s) - arr1[s-1] :0;\n            \n            sum += s<n ?arr2[s] - ((long)(n-s) * (long)i) :0;\n            \n            list.add(sum);\n        }\n        \n        return list;\n        \n    }\n}\n```
['Array', 'Binary Search', 'Prefix Sum', 'C++', 'Java']