
'''simple docstring'''

from __future__ import annotations

from collections.abc import Iterator
from typing import Any






class  A  :





	def __init__(       self      :							str   ,				__magic_name__      :							Any				):


				"""simple docstring"""

				lowerCAmelCase__										=				data
				lowerCAmelCase__										=				None






class  A  :





	def __init__(       self      :							Tuple				):


				"""simple docstring"""

				lowerCAmelCase__										=				None
				lowerCAmelCase__										=				None





	def __iter__(       self      :							Any				):


				"""simple docstring"""

				lowerCAmelCase__										=				self.head
				while self.head:
							yield node.data
							lowerCAmelCase__										=				node.next
							if node == self.head:
										break





	def __len__(       self      :							Tuple				):


				"""simple docstring"""

				return sum(1 for _ in self				)





	def __repr__(       self      :							int				):


				"""simple docstring"""

				return "->".join(str(__magic_name__				) for item in iter(self				)				)





	def 				__SCREAMING_SNAKE_CASE	(       self      :							Union[str, Any]   ,				__magic_name__      :							Any				):


				"""simple docstring"""

				self.insert_nth(len(self				)   ,				__magic_name__				)





	def 				__SCREAMING_SNAKE_CASE	(       self      :							Union[str, Any]   ,				__magic_name__      :							Any				):


				"""simple docstring"""

				self.insert_nth(0   ,				__magic_name__				)





	def 				__SCREAMING_SNAKE_CASE	(       self      :							str   ,				__magic_name__      :							int   ,				__magic_name__      :							Any				):


				"""simple docstring"""

				if index < 0 or index > len(self				):
							raise IndexError("list index out of range."				)
				lowerCAmelCase__										=				Node(__magic_name__				)
				if self.head is None:
							lowerCAmelCase__										=				new_node  # first node points itself
							lowerCAmelCase__										=				lowerCAmelCase__										=				new_node
				elif index == 0:  # insert at head
							lowerCAmelCase__										=				self.head
							lowerCAmelCase__										=				lowerCAmelCase__										=				new_node
				else:
							lowerCAmelCase__										=				self.head
							for _ in range(index - 1				):
										lowerCAmelCase__										=				temp.next
							lowerCAmelCase__										=				temp.next
							lowerCAmelCase__										=				new_node
							if index == len(self				) - 1:  # insert at tail
										lowerCAmelCase__										=				new_node





	def 				__SCREAMING_SNAKE_CASE	(       self      :							List[str]				):


				"""simple docstring"""

				return self.delete_nth(0				)





	def 				__SCREAMING_SNAKE_CASE	(       self      :							str				):


				"""simple docstring"""

				return self.delete_nth(len(self				) - 1				)





	def 				__SCREAMING_SNAKE_CASE	(       self      :							Any   ,				__magic_name__      :							int = 0				):


				"""simple docstring"""

				if not 0 <= index < len(self				):
							raise IndexError("list index out of range."				)
				lowerCAmelCase__										=				self.head
				if self.head == self.tail:  # just one node
							lowerCAmelCase__										=				lowerCAmelCase__										=				None
				elif index == 0:  # delete head node
							lowerCAmelCase__										=				self.tail.next.next
							lowerCAmelCase__										=				self.head.next
				else:
							lowerCAmelCase__										=				self.head
							for _ in range(index - 1				):
										lowerCAmelCase__										=				temp.next
							lowerCAmelCase__										=				temp.next
							lowerCAmelCase__										=				temp.next.next
							if index == len(self				) - 1:  # delete at tail
										lowerCAmelCase__										=				temp
				return delete_node.data







	def 				__SCREAMING_SNAKE_CASE	(       self      :							str				):


				"""simple docstring"""

				return len(self				) == 0







def 	A  (   )       ->							None:







			'''simple docstring'''



			lowerCAmelCase__										=				CircularLinkedList()
			assert len(UpperCamelCase_   ) == 0
			assert circular_linked_list.is_empty() is True
			assert str(UpperCamelCase_   ) == ""

			try:
						circular_linked_list.delete_front()
						raise AssertionError  # This should not happen
			except IndexError:
						assert True  # This should happen

			try:
						circular_linked_list.delete_tail()
						raise AssertionError  # This should not happen
			except IndexError:
						assert True  # This should happen

			try:
						circular_linked_list.delete_nth(-1   )
						raise AssertionError
			except IndexError:
						assert True

			try:
						circular_linked_list.delete_nth(0   )
						raise AssertionError
			except IndexError:
						assert True

			assert circular_linked_list.is_empty() is True
			for i in range(5   ):
						assert len(UpperCamelCase_   ) == i
						circular_linked_list.insert_nth(UpperCamelCase_    ,						i + 1   )
			assert str(UpperCamelCase_   ) == "->".join(str(UpperCamelCase_   ) for i in range(1    ,						6   )   )

			circular_linked_list.insert_tail(6   )
			assert str(UpperCamelCase_   ) == "->".join(str(UpperCamelCase_   ) for i in range(1    ,						7   )   )
			circular_linked_list.insert_head(0   )
			assert str(UpperCamelCase_   ) == "->".join(str(UpperCamelCase_   ) for i in range(0    ,						7   )   )

			assert circular_linked_list.delete_front() == 0
			assert circular_linked_list.delete_tail() == 6
			assert str(UpperCamelCase_   ) == "->".join(str(UpperCamelCase_   ) for i in range(1    ,						6   )   )
			assert circular_linked_list.delete_nth(2   ) == 3

			circular_linked_list.insert_nth(2    ,						3   )
			assert str(UpperCamelCase_   ) == "->".join(str(UpperCamelCase_   ) for i in range(1    ,						6   )   )

			assert circular_linked_list.is_empty() is False


if __name__ == "__main__":
		import doctest

		doctest.testmod()







from collections.abc import Sequence
def 							SCREAMING_SNAKE_CASE_	(					UpperCAmelCase_	:     Sequence[int] | None = None				)			->						int:
       if nums is None or not nums:
              raise ValueError('''Input sequence should not be empty'''				)

       SCREAMING_SNAKE_CASE_							:				Tuple		=nums[0]
       for i in range(1			,							len(UpperCAmelCase_				)				):
              SCREAMING_SNAKE_CASE_							:				Any		=nums[i]
              SCREAMING_SNAKE_CASE_							:				Optional[int]		=max(UpperCAmelCase_			,							ans + num			,							UpperCAmelCase_				)

       return ans


if __name__ == "__main__":
 import doctest

 doctest.testmod()

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