def max_sum_subarray(arr):
    """
    Find maximum the sum of any contiguous subarray
    """
    max_thus_far = 0
    max_ending_here = 0

    for elt in arr:
        max_ending_here += elt

        if max_ending_here < 0:
            max_ending_here = 0

        max_thus_far = max(max_ending_here, max_thus_far)

    return max_thus_far