

from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt


def 							__lowerCAmelCase     (							_UpperCamelCase		:	int						)		->				bool:
 '''simple docstring'''


 SCREAMING_SNAKE_CASE		    =      int(number**0.5						)
 return number == sq * sq


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


 SCREAMING_SNAKE_CASE		    =      x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
 SCREAMING_SNAKE_CASE		    =      x_den * y_den * z_den
 SCREAMING_SNAKE_CASE		    =      gcd(_UpperCamelCase		,				_UpperCamelCase						)
 top //= hcf
 bottom //= hcf
 return top, bottom


def 							__lowerCAmelCase     (							_UpperCamelCase		:	int = 35						)		->				int:
 '''simple docstring'''


 SCREAMING_SNAKE_CASE		    =      set()
 SCREAMING_SNAKE_CASE		    =      42
 SCREAMING_SNAKE_CASE		    =      Fraction(0						)
 SCREAMING_SNAKE_CASE		    =      42

 for x_num in range(1		,				order + 1						):
  for x_den in range(x_num + 1		,				order + 1						):
   for y_num in range(1		,				order + 1						):
    for y_den in range(y_num + 1		,				order + 1						):
     # n=1
     SCREAMING_SNAKE_CASE		    =      x_num * y_den + x_den * y_num
     SCREAMING_SNAKE_CASE		    =      x_den * y_den
     SCREAMING_SNAKE_CASE		    =      gcd(_UpperCamelCase		,				_UpperCamelCase						)
     z_num //= hcf
     z_den //= hcf
     if 0 < z_num < z_den <= order:
      SCREAMING_SNAKE_CASE		    =      add_three(
          _UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase						)
      unique_s.add(_UpperCamelCase						)

     # n=2
     SCREAMING_SNAKE_CASE		    =      (
         x_num * x_num * y_den * y_den + x_den * x_den * y_num * y_num
     )
     SCREAMING_SNAKE_CASE		    =      x_den * x_den * y_den * y_den
     if is_sq(_UpperCamelCase						) and is_sq(_UpperCamelCase						):
      SCREAMING_SNAKE_CASE		    =      int(sqrt(_UpperCamelCase						)						)
      SCREAMING_SNAKE_CASE		    =      int(sqrt(_UpperCamelCase						)						)
      SCREAMING_SNAKE_CASE		    =      gcd(_UpperCamelCase		,				_UpperCamelCase						)
      z_num //= hcf
      z_den //= hcf
      if 0 < z_num < z_den <= order:
       SCREAMING_SNAKE_CASE		    =      add_three(
           _UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase						)
       unique_s.add(_UpperCamelCase						)

                    # n=-1
     SCREAMING_SNAKE_CASE		    =      x_num * y_num
     SCREAMING_SNAKE_CASE		    =      x_den * y_num + x_num * y_den
     SCREAMING_SNAKE_CASE		    =      gcd(_UpperCamelCase		,				_UpperCamelCase						)
     z_num //= hcf
     z_den //= hcf
     if 0 < z_num < z_den <= order:
      SCREAMING_SNAKE_CASE		    =      add_three(
          _UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase						)
      unique_s.add(_UpperCamelCase						)

     # n=2
     SCREAMING_SNAKE_CASE		    =      x_num * x_num * y_num * y_num
     SCREAMING_SNAKE_CASE		    =      (
         x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
     )
     if is_sq(_UpperCamelCase						) and is_sq(_UpperCamelCase						):
      SCREAMING_SNAKE_CASE		    =      int(sqrt(_UpperCamelCase						)						)
      SCREAMING_SNAKE_CASE		    =      int(sqrt(_UpperCamelCase						)						)
      SCREAMING_SNAKE_CASE		    =      gcd(_UpperCamelCase		,				_UpperCamelCase						)
      z_num //= hcf
      z_den //= hcf
      if 0 < z_num < z_den <= order:
       SCREAMING_SNAKE_CASE		    =      add_three(
           _UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase		,				_UpperCamelCase						)
       unique_s.add(_UpperCamelCase						)

 for num, den in unique_s:
  total += Fraction(_UpperCamelCase		,				_UpperCamelCase						)

 return total.denominator + total.numerator


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

