Please check my code

4
1 2 4 5
the ouput should be :
1 5 2 4
but your ouput is different:
debug for this