def minSubArraySum(nums):
    max_sum = 0
    s = 0
    for num in nums:
        s += -num
        if (s < 0):
            s = 0
        max_sum = max(s, max_sum)
    if max_sum == 0:
        max_sum = max(-i for i in nums)
    min_sum = -max_sum
    return min_sum
def minSubArraySum(nums):
    max_sum = 0
    s = 0
    _num_i = 0
    while _num_i < len(nums):
        num = nums[_num_i]
        s += -num
        if s < 0:
           
            s = 0
        max_sum = max(s, max_sum)
        _num_i += 1
    if max_sum == 0:
        max_sum = max(-i for i in nums)
    min_sum = -max_sum
    return min_sum