def binarySearchB(array, l, r, x):
    """
    Search function using binary search algorithm.
    array - sorted array
    l - left index(in python 0)
    r - right index(len(array))
    x - value of index search
    """
    if r >= l:
        while r > l:
            mid = (r + l) // 2

            if array[mid] < x:
                l = mid + 1
            else:
                r = mid
        if array[r] == x:
            return r
    else:
        return -1