For what testcases this code is showing wrong output:

code:

@myself.yash.srivastav Consider the test case:
10
-1 0 1 2 3 4 6 6 7 9
3
3
6
10

Your Output:
4 4
7 7
-1 -1

Expected Output:
4 4
6 7
-1 -1