def binary_search(l : list, z : int) -> int: # z = the value being searched
front = 0
rear = len(l) - 1
mid = (front + rear) // 2
while front <= rear and l[mid] != z:
if l[mid] > z:
rear = mid - 1
else:
front = mid + 1
mid = (front + rear) // 2
return mid if l[mid] == z else -1