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?

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?

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