from copy import deepcopy


class Solution(object):

    def maxSubArray(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        max_sum = 0
        max_ending_here = 0
        for i in range(len(nums)):
            max_ending_here = max_ending_here + nums[i]
            if max_ending_here < 0:
                max_ending_here = 0
            if max_ending_here > max_sum:
                max_sum = max_ending_here
        for num in nums:
            if num > 0:
                return max_sum
        min_neg = nums[0]
        for num in nums:
            if num > min_neg:
                min_neg = num
        return min_neg


sol = Solution()
print(sol.maxSubArray([-1]))

37069c7259a0332adb8190346866d31af770627f
<mask token>


class Solution(object):

    def maxSubArray(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        max_sum = 0
        max_ending_here = 0
        for i in range(len(nums)):
            max_ending_here = max_ending_here + nums[i]
            if max_ending_here < 0:
                max_ending_here = 0
            if max_ending_here > max_sum:
                max_sum = max_ending_here
        for num in nums:
            if num > 0:
                return max_sum
        min_neg = nums[0]
        for num in nums:
            if num > min_neg:
                min_neg = num
        return min_neg


<mask token>

<mask token>


class Solution(object):

    def maxSubArray(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        max_sum = 0
        max_ending_here = 0
        for i in range(len(nums)):
            max_ending_here = max_ending_here + nums[i]
            if max_ending_here < 0:
                max_ending_here = 0
            if max_ending_here > max_sum:
                max_sum = max_ending_here
        for num in nums:
            if num > 0:
                return max_sum
        min_neg = nums[0]
        for num in nums:
            if num > min_neg:
                min_neg = num
        return min_neg


<mask token>
print(sol.maxSubArray([-1]))

<mask token>


class Solution(object):

    def maxSubArray(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        max_sum = 0
        max_ending_here = 0
        for i in range(len(nums)):
            max_ending_here = max_ending_here + nums[i]
            if max_ending_here < 0:
                max_ending_here = 0
            if max_ending_here > max_sum:
                max_sum = max_ending_here
        for num in nums:
            if num > 0:
                return max_sum
        min_neg = nums[0]
        for num in nums:
            if num > min_neg:
                min_neg = num
        return min_neg


sol = Solution()
print(sol.maxSubArray([-1]))

from copy import deepcopy


class Solution(object):

    def maxSubArray(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        max_sum = 0
        max_ending_here = 0
        for i in range(len(nums)):
            max_ending_here = max_ending_here + nums[i]
            if max_ending_here < 0:
                max_ending_here = 0
            if max_ending_here > max_sum:
                max_sum = max_ending_here
        for num in nums:
            if num > 0:
                return max_sum
        min_neg = nums[0]
        for num in nums:
            if num > min_neg:
                min_neg = num
        return min_neg


sol = Solution()
print(sol.maxSubArray([-1]))
