def count_route_distance(route, distances):
    """Count distance of route based on distances between targets."""
    total_distance = 0
    source = 0
    for target in route:
        total_distance += distances[source][target]
        source = target
    return total_distance