import functools


def max_subarray_cache(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_cache([-2,1,-3,4,-1,2,1,-5,4])
        6
        >>> max_subarray_cache([1])
        1
        >>> max_subarray_cache([5,4,-1,7,8])
        23
        >>> max_subarray_cache([])
        0

    """
    if not nums:
        return 0

    @functools.lru_cache(maxsize=None)
    def max_subarray_sum_ending_at_index(i: int) -> int:
        ## Base Case ##
        if i < 0:
            return 0

        return max(nums[i], max_subarray_sum_ending_at_index(i - 1) + nums[i])

    return max(max_subarray_sum_ending_at_index(i) for i in range(len(nums)))