import bisect


def closestValue(v,values):
    
    """ Find the value that is closest to v in values """
    
    i = bisect.bisect_left(values,v)
    if i == len(values):
        return i-1
    elif values[i] == v:
        return i
    elif i > 0:
        j = i-1
        if values[i] - v > v - values[j]:
            return j
    return i