human
Maximize profit possible by selling M products such that profit of a product is the number of products left of that supplier | Function to find the maximum profit by selling M number of products.
Initialize a Max - Heap to keep track of the maximum value.
Stores the maximum profit.
Traverse the array and push all the elements in max_heap.
Iterate a loop until M > 0.
Decrement the value of M by 1.
Pop the maximum element from the heap.
Update the maxProfit.
Push ( X - 1 ) to max heap.
Print the result.
Driver code"
How can the above be solved in Python?

Can you provide a code to maximize profit possible by selling M products such that profit of a product is the number of products left of that supplier and the other steps required?
assistant
#Here is code to maximize profit possible by selling M products such that profit of a product is the number of products left of that supplier and the other steps required.
 def findMaximumProfit ( arr , M , N ) :
	max_heap = [ ]
	maxProfit = 0
	for i in range ( 0 , N ) :
		max_heap . append ( arr [ i ] )
	max_heap . sort ( )
	max_heap . reverse ( )
	while ( M > 0 ) :
		M -= 1
		X = max_heap [ 0 ]
		max_heap . pop ( 0 )
		maxProfit += X
		max_heap . append ( X - 1 )
		max_heap . sort ( )
		max_heap . reverse ( )
	print ( maxProfit )
arr = [ 4 , 6 ]
M = 4
N = len ( arr )
findMaximumProfit ( arr , M , N )