

def 							__lowerCAmelCase     (							_UpperCamelCase		:	list[list[int]]		,				_UpperCamelCase		:	int		,				_UpperCamelCase		:	int		,				_UpperCamelCase		:	set						)		->				int:
 '''simple docstring'''


 SCREAMING_SNAKE_CASE    ,						SCREAMING_SNAKE_CASE		    =      len(_UpperCamelCase						), len(grid[0]						)
 if (
     min(_UpperCamelCase		,				_UpperCamelCase						) < 0
     or row == row_length
     or col == col_length
     or (row, col) in visit
     or grid[row][col] == 1
 ):
  return 0
 if row == row_length - 1 and col == col_length - 1:
  return 1

 visit.add((row, col)						)

 SCREAMING_SNAKE_CASE		    =      0
 count += depth_first_search(_UpperCamelCase		,				row + 1		,				_UpperCamelCase		,				_UpperCamelCase						)
 count += depth_first_search(_UpperCamelCase		,				row - 1		,				_UpperCamelCase		,				_UpperCamelCase						)
 count += depth_first_search(_UpperCamelCase		,				_UpperCamelCase		,				col + 1		,				_UpperCamelCase						)
 count += depth_first_search(_UpperCamelCase		,				_UpperCamelCase		,				col - 1		,				_UpperCamelCase						)

 visit.remove((row, col)						)
 return count


if __name__ == "__main__":
      import doctest

      doctest.testmod()




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

