def aa(nums): if not nums: return False current=0 ret=float('-inf') for i in nums: if current <=0: current =i else: current +=i ret=max(current,ret) return ret print(aa([1,2,3,4])) def aa(nums): current=nums[0] leng=len(nums)-1 m=0 n=0 for i in nums[1:]: m=current*i n=current+i if m>n: current=m else: current=n return current print(aa([1,2,3,4]))