def max_subarray_recursive(nums: list[int]) -> int:
    """Returns the largest non-empty contiguous subarray sum

    Args:
        nums: An array of integers drawn from the range [-10^5, 10^5]

    Examples:
        >>> max_subarray_recursive([-2,1,-3,4,-1,2,1,-5,4])
        6
        >>> max_subarray_recursive([1])
        1
        >>> max_subarray_recursive([5,4,-1,7,8])
        23
        >>> max_subarray_recursive([])
        0

    """
    ## EDGE CASE ##
    if not nums:
        return 0

    def calculate_max_subarray_sum(index_to_include: int, max_sum=-float("inf")):
        if index_to_include == 0:  # base case
            return nums[0], nums[0]

        max_subarray_sum = nums[index_to_include]  # initialize
        prev_max_subarray_sum, prev_max_sum = calculate_max_subarray_sum(
            index_to_include - 1, max_sum
        )
        if prev_max_subarray_sum > 0:
            max_subarray_sum += prev_max_subarray_sum

        return max_subarray_sum, max(prev_max_sum, max_subarray_sum)

    # Update each idx to contain the maximum contiguous subarray sum that could
    # be obtained by the inclusion of the element at that idx; in other words,
    # include a previously running subarray sum if it would produce a larger
    # sum, else ONLY include the element at that idx (thus starting a new
    # subarray partition)
    _, max_sum = calculate_max_subarray_sum(len(nums) - 1)
    return max_sum