Implement a modified binary search with repeated elements in the sorted array.