def L(i, d_in, n_us):
    """
    Helper function for calculating fifo load, representing the increase in the
    fifo value during readout period ``i``. Maximum FIFO value can be found
    by summing from ``i=-1`` to ``i=d_in-1``, inclusive.

    :param i: iterator index

    :param d_in: in degree of node in downstream network

    :param n_us: sorted list of number of downstream parents of node (0 == least upstream children) of each connection in downstream network

    :returns: ``int``

    """
    if i == -1:
        return 1
    if i == 0:
        return d_in - 1
    if i == 1:
        return (d_in - i) * (n_us[0] - 1)
    return (d_in - i) * (n_us[i - 1] - n_us[i - 2])
