




from __future__ import annotations



def       UpperCAmelCase       (     _snake_case						, _snake_case = None						, _snake_case = None							):
       if start is None:
              lowerCAmelCase   =		0

       if end is None:
              lowerCAmelCase   =		len(_snake_case							) - 1

       if start >= end:
              return

       lowerCAmelCase   =		(start + end) // 2

       slowsort(_snake_case						, _snake_case						, _snake_case							)
       slowsort(_snake_case						, mid + 1						, _snake_case							)

       if sequence[end] < sequence[mid]:
              lowerCAmelCase   ,     lowerCAmelCase   =		sequence[mid], sequence[end]

       slowsort(_snake_case						, _snake_case						, end - 1							)


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

  testmod()









from collections.abc import Sequence



def       UpperCAmelCase       (     _snake_case						, _snake_case = False							):
							if not arr:
														return 0

							lowerCAmelCase   =		0 if allow_empty_subarrays else float('''-inf'''							)
							lowerCAmelCase   =		0.0
							for num in arr:
														lowerCAmelCase   =		max(0 if allow_empty_subarrays else num						, curr_sum + num							)
														lowerCAmelCase   =		max(_snake_case						, _snake_case							)

							return max_sum


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

		testmod()

		UpperCAmelCase_						=[-2, 1, -3, 4, -1, 2, 1, -5, 4]
		print(F'''{max_subarray_sum(nums) = }''')



