def guessNumber(n):
lo, hi = 1, n+1
while lo < hi:
mid = (lo+hi)//2
result = guess(mid)
if result == 0:
return mid
elif result == 1:
lo = mid+1
elif result == -1:
hi = mid
return mid