It does't pass two test cases. can u help me? for code of Sum it up!

Code is here:

In question it is given that the outputs must be in lexicographically manner
wrong order is:- 1 3 4 then 1 2 5
Correct way is:- 1 2 5 then 1 3 4

It prints in lexicographical order and also it satisfies above test case that u gave

take the example:-
4
1 3 11 12
15

your code output is:-
3 12
1 3 11

but it should be
1 3 11
3 12