def Pathlen_ULdigraph_Range2(N,L):
    """
    Longest possible pathlength of a strongly connected digraph (ultra-long limit).
    Valid in the range when L >= (N-1) + 1/2 N(N-1), or density >= 1/2 + 1/N.

    Calculates the longest possible pathlength a connected directed graph of
    arbitrary number of nodes N and number of directed arcs L could possibly
    have, whenever L > 1/2 N(N-1) + (N-1).

    Reference and citation
    ^^^^^^^^^^^^^^^^^^^^^^
    G. Zamora-López & R. Brasselet "Sizing complex networks" Commun Phys 2:144 (2019)

    Parameters
    ----------
    N : integer
        Number of nodes in the digraph.
    L : integer
        Number of directed arcs in the digraph.

    Returns
    -------
    avpathlen : float
        The average pathlength of a strongly connected ultra-short digraph.

    See Also
    --------
    Pathlen_ULdigraph :
    Pathlen_ULdigraph_Range1_MBS :
    Pathlen_ULdigraph_Range1_Approx :
    Pathlen_ULdigraph_Intermediate :
    """
    # 0) SECURITY CHECKS
    if N < 2: raise ValueError( "Network needs at least two nodes, N > 1" )
    Lstart = int( 0.5*N*(N-1) + (N-1) );    Ltot = N*(N-1)
    if L < Lstart:  raise ValueError( "L out of range, min(L) = 1/2*N*(N-1) + (N-1)" )
    if L > Ltot:    raise ValueError( "L out of range, max(L) = N*(N-1)." )

    # 1) CALCULATE THE CORRESPONDING PATHLENGTH
    Lr = L - Lstart
    term1 = float(N + 4.0)/6
    term2 = float(Lr) / N

    # Calculate term #3, which includes a series without a closed formula.
    partsum = 0
    finished = False
    counter = 0
    for i in range(1,N):
        if finished: break
        for j in range(i):
            if counter == Lr:
                finished = True
                break
            partsum += i
            counter += 1
    term3 = float(partsum) / Ltot

    # Sum all the contributiona
    avpathlen = term1 - term2 + term3
    return avpathlen