
"""simple docstring"""







from functools import lru_cache
@lru_cache
def   __UpperCamelCase   (					SCREAMING_SNAKE_CASE )  ->     int:







							"""simple docstring"""


							if num < 0:
														raise ValueError("Number should not be negative." )

							return 1 if num in (0, 1) else num * factorial(num - 1 )


if __name__ == "__main__":
		import doctest

		doctest.testmod()


"""simple docstring"""







from collections.abc import Sequence
def   __UpperCamelCase   (					SCREAMING_SNAKE_CASE = None )  ->     int:







							"""simple docstring"""


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

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

							return ans


if __name__ == "__main__":
		import doctest

		doctest.testmod()

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