Binary search algorithm for sorted array.