def expected_loss(a0, b0, a1, b1):
    """Closed-form expectation max(difference Pareto, 0)."""
    if b1 > b0:
        r = (b0 / b1) ** a0
        t = a1 * b1 / (a1 - 1) * (1 - r)
        q = a0 / (a0 - 1) * (b0 - b1 * r)
        s = a0 * b1 / (a0 + a1 - 1) * r / (a1 - 1)
        return t - q + s
    else:
        return a0 * b0 / (a0 + a1 - 1) * (b1 / b0) ** a1 / (a1 - 1)
