




"""simple docstring"""




from __future__ import annotations

from collections.abc import MutableSequence






class 					__magic_name__							:






				'''simple docstring'''





				def __init__( self	,				_a	,				_a				):





							"""simple docstring"""







							if len(_a				) != degree + 1:
										raise ValueError(
										    """The number of coefficients should be equal to the degree + 1."""				)

							lowerCamelCase       =      list(_a				)
							lowerCamelCase       =      degree





				def __add__( self	,				_a				):





							"""simple docstring"""







							if self.degree > polynomial_a.degree:
										lowerCamelCase       =      self.coefficients[:]
										for i in range(polynomial_a.degree + 1				):
													coefficients[i] += polynomial_a.coefficients[i]
										return Polynomial(self.degree	,				_a				)
							else:
										lowerCamelCase       =      polynomial_a.coefficients[:]
										for i in range(self.degree + 1				):
													coefficients[i] += self.coefficients[i]
										return Polynomial(polynomial_a.degree	,				_a				)





				def __sub__( self	,				_a				):





							"""simple docstring"""
							return self + polynomial_a * Polynomial(0	,				[-1]				)





				def __neg__( self				):





							"""simple docstring"""
							return Polynomial(self.degree	,				[-c for c in self.coefficients]				)





				def __mul__( self	,				_a				):





							"""simple docstring"""
							lowerCamelCase       =      [0] * (self.degree + polynomial_a.degree + 1)
							for i in range(self.degree + 1				):
										for j in range(polynomial_a.degree + 1				):
													coefficients[i + j] += (
													    self.coefficients[i] * polynomial_a.coefficients[j]
													)

							return Polynomial(self.degree + polynomial_a.degree	,				_a				)





				def      _lowerCAmelCase       ( self	,				_a				):





							"""simple docstring"""
							lowerCamelCase       =      0
							for i in range(self.degree + 1				):
										result += self.coefficients[i] * (substitution**i)
							return result





				def __str__( self				):





							"""simple docstring"""
							lowerCamelCase       =      ''
							for i in range(self.degree	,				-1	,				-1				):
										if self.coefficients[i] == 0:
													continue
										elif self.coefficients[i] > 0:
													if polynomial:
																polynomial += " + "
										else:
													polynomial += " - "

										if i == 0:
													polynomial += str(abs(self.coefficients[i]				)				)
										elif i == 1:
													polynomial += str(abs(self.coefficients[i]				)				) + "x"
										else:
													polynomial += str(abs(self.coefficients[i]				)				) + "x^" + str(_a				)

							return polynomial





				def __repr__( self				):





							"""simple docstring"""
							return self.__str__()





				def      _lowerCAmelCase       ( self				):





							"""simple docstring"""
							lowerCamelCase       =      [0] * self.degree
							for i in range(self.degree				):
										lowerCamelCase       =      self.coefficients[i + 1] * (i + 1)
							return Polynomial(self.degree - 1	,				_a				)





				def      _lowerCAmelCase       ( self	,				_a = 0				):





							"""simple docstring"""
							lowerCamelCase       =      [0] * (self.degree + 2)
							lowerCamelCase       =      constant
							for i in range(self.degree + 1				):
										lowerCamelCase       =      self.coefficients[i] / (i + 1)
							return Polynomial(self.degree + 1	,				_a				)





				def __eq__( self	,				_a				):





							"""simple docstring"""







							if not isinstance(_a	,				_a				):
										return False

							if self.degree != polynomial_a.degree:
										return False

							for i in range(self.degree + 1				):
										if self.coefficients[i] != polynomial_a.coefficients[i]:
													return False

							return True





				def __ne__( self	,				_a				):





							"""simple docstring"""
							return not self.__eq__(_a				)









"""simple docstring"""




from collections.abc import Sequence



def 					a__				(       snake_case__ ,				snake_case__ = False       )		->      float:
			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()

					lowerCAmelCase							:    Optional[int]  							=							[-2, 1, -3, 4, -1, 2, 1, -5, 4]
					print(F"""{max_subarray_sum(nums) = }""")



