Comments

No it's not necessary.But you cannot just take "any" smallest non negative integer. for example-Mex(5,2,0,3,0,5) will be 1 because 1 is the smallest non negative integer which does not appear in this array.

in first operation,you can take l=1 and r=6(basically the entire array),so the new array will be 1,1,1,1,1,1. In second operation,again select l=1 and r=6,the array will now be 0,0,0,0,0,0.