Getting wrong answer in all test cases

implemented binary search and runs fine on sample test case. but gives wrong answer on each test case. not getting where the problem is.