human
Maximum number of elements that can be removed such that MEX of the given array remains unchanged | Function to find the maximum number of elements that can be removed.
Initialize hash [ ] with 0 s.
Initialize MEX.
Set hash [ i ] = 1 , if i is present in arr [ ].
Find MEX from the hash.
Print the maximum numbers that can be removed.
Driver Code.
Given array.
Size of the array.
Function Call"
How can the above be solved in Python?

Write me a code to maximum number of elements that can be removed such that MEX of the given array remains unchanged and the other steps required?
assistant
#Here is code to maximum number of elements that can be removed such that MEX of the given array remains unchanged and the other steps required.
 def countRemovableElem ( arr , N ) :
	hash = [ 0 ] * ( N + 1 )
	mex = N + 1
	for i in range ( 0 , N ) :
		if ( arr [ i ] <= N ) :
			hash [ arr [ i ] ] = 1
	for i in range ( 1 , N + 1 ) :
		if ( hash [ i ] == 0 ) :
			mex = i
			break
	print ( N - ( mex - 1 ) )
if __name__ == ' _ _ main _ _ ' :
	arr = [ 2 , 3 , 5 , 1 , 6 ]
	N = len ( arr )
	countRemovableElem ( arr , N )