def METHOD_NAME(distances, route):
    """
    Parameters
    ----------
    distances: ndarray
        distance array, for which distances[i, j] is the distance from the ith to the jth point
    route: ndarray
        array of indices defining the path
    """
    return distances[route[:-1], route[1:]].sum()