Amiguity in expected output


#1

suppose the input is
20
3 10 14 18
output = 10 14 18 (so far this is fine)
Now if the order is changed i.e;
20 3 14 10 18
output(what it has to be) = 10 14 18
what it is showing = 14 18 10

How is this possible?


#2

Also think of this case 4 ,[1 2 3] what shall be the output and what is the expected output?