





from __future__ import annotations

from collections.abc import Callable

__UpperCamelCase:	List[str] = list[list[float | int]]


def       SCREAMING_SNAKE_CASE__  (       _lowercase     : Matrix   ,    _lowercase     : Matrix			)   ->							Matrix:




		'''simple docstring'''
		lowercase__					:      Dict      =		len(_UpperCamelCase			)
		lowercase__					:      Tuple      =		[[0 for _ in range(size + 1			)] for _ in range(_UpperCamelCase			)]
		lowercase__					:      Union[str, Any]      =		42
		lowercase__					:      int      =		42
		lowercase__					:      Any      =		42
		lowercase__					:      List[str]      =		42
		lowercase__					:      Tuple      =		42
		lowercase__					:      List[Any]      =		42

		for row in range(_UpperCamelCase			):
				for col in range(_UpperCamelCase			):
						lowercase__					:      Union[str, Any]      =		matrix[row][col]

				lowercase__					:      Tuple      =		vector[row][0]

		lowercase__					:      Union[str, Any]      =		0
		lowercase__					:      Optional[Any]      =		0
		while row < size and col < size:
				# pivoting
				lowercase__					:      Tuple      =		max((abs(augmented[rowa][col]			), rowa) for rowa in range(_UpperCamelCase   ,    _UpperCamelCase			)			)[
				    1
				]
				if augmented[pivot_row][col] == 0:
						col += 1
						continue
				else:
						lowercase__   ,				lowercase__					:      Union[str, Any]      =		augmented[pivot_row], augmented[row]

				for rowa in range(row + 1   ,    _UpperCamelCase			):
						lowercase__					:      int      =		augmented[rowa][col] / augmented[row][col]
						lowercase__					:      Tuple      =		0
						for cola in range(col + 1   ,    size + 1			):
								augmented[rowa][cola] -= augmented[row][cola] * ratio

				row += 1
				col += 1

		# back substitution
		for col in range(1   ,    _UpperCamelCase			):
				for row in range(_UpperCamelCase			):
						lowercase__					:      int      =		augmented[row][col] / augmented[col][col]
						for cola in range(_UpperCamelCase   ,    size + 1			):
								augmented[row][cola] -= augmented[col][cola] * ratio

								# round to get rid of numbers like 2.000000000000004
		return [
		    [round(augmented[row][size] / augmented[row][row]   ,    10			)] for row in range(_UpperCamelCase			)
		]


def       SCREAMING_SNAKE_CASE__  (       _lowercase     : list[int]			)   ->							Callable[[int], int]:




		'''simple docstring'''
		lowercase__					:      Optional[Any]      =		len(_UpperCamelCase			)
		lowercase__					:      Dict      =		[[0 for _ in range(_UpperCamelCase			)] for _ in range(_UpperCamelCase			)]
		lowercase__					:      Optional[int]      =		[[0] for _ in range(_UpperCamelCase			)]
		lowercase__					:      List[Any]      =		42
		lowercase__					:      int      =		42
		lowercase__					:      List[str]      =		42
		lowercase__					:      Optional[Any]      =		42

		for x_val, y_val in enumerate(_UpperCamelCase			):
				for col in range(_UpperCamelCase			):
						lowercase__					:      Dict      =		(x_val + 1) ** (size - col - 1)
				lowercase__					:      Optional[Any]      =		y_val

		lowercase__					:      List[Any]      =		solve(_UpperCamelCase   ,    _UpperCamelCase			)

		def interpolated_func(_lowercase     : int			) -> int:
				return sum(
				    round(coeffs[x_val][0]			) * (var ** (size - x_val - 1))
				    for x_val in range(_UpperCamelCase			)			)

		return interpolated_func


def       SCREAMING_SNAKE_CASE__  (       _lowercase     : int			)   ->							int:




		'''simple docstring'''
		return (
		    1
		    - variable
		    + variable**2
		    - variable**3
		    + variable**4
		    - variable**5
		    + variable**6
		    - variable**7
		    + variable**8
		    - variable**9
		    + variable**10
		)


def       SCREAMING_SNAKE_CASE__  (       _lowercase     : Callable[[int], int] = question_function   ,    _lowercase     : int = 10			)   ->							int:




		'''simple docstring'''
		lowercase__					:      Union[str, Any]      =		[func(_UpperCamelCase			) for x_val in range(1   ,    order + 1			)]

		lowercase__					:      str      =		[
		    interpolate(data_points[:max_coeff]			) for max_coeff in range(1   ,    order + 1			)
		]

		lowercase__					:      Optional[Any]      =		0
		lowercase__					:      str      =		42
		lowercase__					:      Optional[int]      =		42

		for poly in polynomials:
				lowercase__					:      Optional[int]      =		1
				while func(_UpperCamelCase			) == poly(_UpperCamelCase			):
						x_val += 1

				ret += poly(_UpperCamelCase			)

		return ret


if __name__ == "__main__":
			print(F'{solution() = }')





from collections.abc import Sequence


def 							__lowerCAmelCase     (							_UpperCamelCase		:	Sequence[int] | None = None						)		->				int:
 '''simple docstring'''


 if nums is None or not nums:
  raise ValueError('Input sequence should not be empty'						)

 SCREAMING_SNAKE_CASE		    =      nums[0]
 for i in range(1		,				len(_UpperCamelCase						)						):
  SCREAMING_SNAKE_CASE		    =      nums[i]
  SCREAMING_SNAKE_CASE		    =      max(_UpperCamelCase		,				ans + num		,				_UpperCamelCase						)

 return ans


if __name__ == "__main__":
      import doctest

      doctest.testmod()

      # Try on a sample input from the user
      a_     :    str     		=   int(input("Enter number of elements : ").strip())
      a_     :    Any     		=   list(map(int, input("\nEnter the numbers : ").strip().split()))[:n]
      print(max_subsequence_sum(array))

