```
def maxSubArray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
n = len(nums)
if n == 1:
return nums[0]
x = nums[0]
y = 0
z = nums[0]
for i in range(1,n):
if x-y > z:
z=x-y
if x < y:
y = x
x+= nums[i]
if x-y > z:
z=x-y
if x < y:
y = x
return z
```