static int binarySearch(int start, int end, int x, int[] arr) {
while (start <= end) {
int mid = (start + end) / 2;
if (x > arr[mid]) {
start = mid + 1;
} else if (x < arr[mid]) {
end = mid - 1;
} else {
return mid;
}
}
return -1;
}