def calculate_total_distance(
        distances: dict[str, dict[str, float]],
        city_path: list[str]
    ) -> int:
    """
    Calculate the total distance for a specified path of cities.
    Distances are directed. Each leg must be stored from its origin to its
    destination; a stored reverse leg does not make the leg feasible.

    Parameters
    ----------
    distances : dict[str, dict[str, float]]
        A nested (non-empty) dictionary where keys are origin cities and
        values are dictionaries with destination cities and their distances.
    city_path : list[str]
        A list of cities representing the travel path. The list has at least
        two cities.

    Returns
    -------
    int
        The total distance for the path or -1 if the path is infeasible.

    Examples
    --------
    >>> distances = {
    ...   'CityA': {'CityB': 10, 'CityC': 20},
    ...   'CityB': {'CityC': 30},
    ...   'CityC': {'CityA': 20},
    ...   'CityD': {'CityB': 20},
    ... }
    >>> calculate_total_distance(distances, ['CityA', 'CityB', 'CityC'])
    40
    >>> calculate_total_distance(distances, ['CityA', 'CityD'])
    -1
    """
    raise NotImplementedError("Complete this function.")
