



'''simple docstring'''




from collections.abc import Sequence


def 				lowerCAmelCase_   (	_lowerCamelCase:   Sequence[float]       ,      _lowerCamelCase:   bool = False					):
		if not arr:
				return 0

		__SCREAMING_SNAKE_CASE       :		Optional[int]           =		0 if allow_empty_subarrays else float("""-inf"""					)
		__SCREAMING_SNAKE_CASE       :		Dict           =		0.0
		for num in arr:
				__SCREAMING_SNAKE_CASE       :		Union[str, Any]           =		max(0 if allow_empty_subarrays else num       ,      curr_sum + num					)
				__SCREAMING_SNAKE_CASE       :		Optional[int]           =		max(_lowerCamelCase       ,      _lowerCamelCase					)

		return max_sum


if __name__ == "__main__":
						from doctest import testmod

						testmod()

						UpperCamelCase__       :	Tuple    = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
						print(f"{max_subarray_sum(nums) = }")




'''simple docstring'''




from __future__ import annotations


def 				lowerCAmelCase_   (	_lowerCamelCase:   list[int]					):
		if not nums:
				return 0
		__SCREAMING_SNAKE_CASE       :		Optional[int]           =		nums[0]
		__SCREAMING_SNAKE_CASE       :		Union[str, Any]           =		0
		for num in nums[1:]:
				__SCREAMING_SNAKE_CASE       ,						__SCREAMING_SNAKE_CASE       :		Any           =		(
				    max_excluding + num,
				    max(_lowerCamelCase       ,      _lowerCamelCase					),
				)
		return max(_lowerCamelCase       ,      _lowerCamelCase					)


if __name__ == "__main__":
						import doctest

						doctest.testmod()