from typing import List


def kadane_algorithm(array: List[int]) -> int:
    """
    Use Kadane's algorithm to solve the max sum subarray problem.
    :param array: the array to process
    :return: the maximum value amongst all consecutive subarrays.

    >>> kadane_algorithm([34, -50, 42, 14, -5, 86])
    137
    >>> kadane_algorithm([-5, -1, -8, -9])
    0
    """
    current_max_ending = 0
    max_ending = 0
    for v in array:
        current_max_ending += v
        if max_ending < current_max_ending:
            max_ending = current_max_ending

        if current_max_ending < 0:
            current_max_ending = 0

    return max_ending