Expected output is incorrecct for case 1 1 1 2 1 1


#1

Your Input:
6 1 1 1 2 1 1
2
Expected output is -1

Seems like the program in expected output is wrong


#2

the program expects input of none duplicate integers i think


#3

Your test case is wrong
The array is in non decreasing order.
Also, the array can have duplicate values.
Let me know, if I am clear to you.

Happy coding !!