def best_fit(li, value):
    index = min(bisect_left(li, value), len(li) - 1)
    if index in (0, len(li)):
        return index
    if li[index] - value < value - li[index-1]:
        return index
    else:
        return index-1