instructions.totalCost to store the total cost of insertions.instructions:
a. Query the BIT to find the number of elements less than the current element (prefix sum).
b. Query the BIT to find the number of elements greater than the current element (total sum - prefix sum up to and including the current element).
c. Calculate the cost as the minimum of the two values obtained in steps a and b.
d. Add the cost to totalCost.
e. Update the BIT with the current element.totalCost modulo 10^9 + 7.