human
Rearrange array elements to maximize the sum of MEX of all prefix arrays | Function to find the maximum sum of MEX of prefix arrays for any arrangement of the given array.
Stores the final arrangement.
Sort the array in increasing order.
Iterate over the array arr [ ].
Iterate over the array , arr [ ] and push the remaining occurrences of the elements into ans [ ].
Prthe array , ans [ ].
Driver Code.
Given array.
Store the size of the array.
Function Call"
How can the above be solved in Python?

Can you provide a code to rearrange array elements to maximize the sum of MEX of all prefix arrays and the other steps required?
assistant
#Here is code to rearrange array elements to maximize the sum of MEX of all prefix arrays and the other steps required.
 def maximumMex ( arr , N ) :
	ans = [ ]
	arr = sorted ( arr )
	for i in range ( N ) :
		if ( i == 0 or arr [ i ] != arr [ i - 1 ] ) :
			ans . append ( arr [ i ] )
	for i in range ( N ) :
		if ( i > 0 and arr [ i ] == arr [ i - 1 ] ) :
			ans . append ( arr [ i ] )
	for i in range ( N ) :
		print ( ans [ i ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 0 , 0 ]
	N = len ( arr )
	maximumMex ( arr , N )