



from queue import PriorityQueue
from typing import Any

import numpy as np




def 	UpperCAmelCase   (						_lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    ):
			for nxt, d in graph[v]:
						if nxt in visited_forward:
									continue
						A							:					List[str]              =						cst_fwd.get(_lowerCamelCase ,    np.inf    )
						A							:					str              =						cst_fwd[v] + d
						if new_cost_f < old_cost_f:
									queue.put((new_cost_f, nxt)    )
									A							:					Union[str, Any]              =						new_cost_f
									A							:					List[Any]              =						v
						if nxt in visited_backward:
									if cst_fwd[v] + d + cst_bwd[nxt] < shortest_distance:
												A							:					Optional[Any]              =						cst_fwd[v] + d + cst_bwd[nxt]
			return shortest_distance




def 	UpperCAmelCase   (						_lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase    ):
			A							:					Any              =						-1

			A							:					Tuple              =						set()
			A							:					Any              =						set()
			A							:					Union[str, Any]              =						{source: 0}
			A							:					str              =						{destination: 0}
			A							:					int              =						{source: None}
			A							:					List[str]              =						{destination: None}
			A							:					PriorityQueue[Any]              =						PriorityQueue()
			A							:					PriorityQueue[Any]              =						PriorityQueue()

			A							:					Dict              =						np.inf

			queue_forward.put((0, source)    )
			queue_backward.put((0, destination)    )

			if source == destination:
						return 0

			while not queue_forward.empty() and not queue_backward.empty():
						A       , A							:					Optional[Any]              =						queue_forward.get()
						visited_forward.add(_lowerCamelCase    )

						A       , A							:					int              =						queue_backward.get()
						visited_backward.add(_lowerCamelCase    )

						A							:					Any              =						pass_and_relaxation(
						    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    )

						A							:					Union[str, Any]              =						pass_and_relaxation(
						    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    _lowerCamelCase ,    )

						if cst_fwd[v_fwd] + cst_bwd[v_bwd] >= shortest_distance:
									break

			if shortest_distance != np.inf:
						A							:					Union[str, Any]              =						shortest_distance
			return shortest_path_distance


__SCREAMING_SNAKE_CASE           =  {
    """B""": [["""C""", 1]],
    """C""": [["""D""", 1]],
    """D""": [["""F""", 1]],
    """E""": [["""B""", 1], ["""G""", 2]],
    """F""": [],
    """G""": [["""F""", 1]],
}
__SCREAMING_SNAKE_CASE           =  {
    """B""": [["""E""", 1]],
    """C""": [["""B""", 1]],
    """D""": [["""C""", 1]],
    """F""": [["""D""", 1], ["""G""", 1]],
    """E""": [[None, np.inf]],
    """G""": [["""E""", 2]],
}

if __name__ == "__main__":
							import doctest

							doctest.testmod()




from collections.abc import Sequence




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

			A							:					Dict              =						nums[0]
			for i in range(1 ,    len(_lowerCamelCase    )    ):
						A							:					Tuple              =						nums[i]
						A							:					List[Any]              =						max(_lowerCamelCase ,    ans + num ,    _lowerCamelCase    )

			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))