nums array.ps such that ps[i] is the sum of the first i elements of nums.ss such that ss[i] is the sum of the elements from i to the end of nums.q in queries:
a. Use binary search to find the smallest index pos where nums[pos] >= q.
b. Calculate the number of operations needed to make all elements before pos equal to q using the prefix sum.
c. Calculate the number of operations needed to make all elements from pos onwards equal to q using the suffix sum.
d. Add the results from steps b and c to get the total number of operations for the query.