



'''simple docstring'''


import argparse
import json
import os
import sys
import tempfile
import unittest
from argparse import Namespace
from dataclasses import dataclass, field
from enum import Enum
from pathlib import Path
from typing import List, Literal, Optional

import yaml

from transformers import HfArgumentParser, TrainingArguments
from transformers.hf_argparser import make_choice_type_function, string_to_bool


# Since Python 3.10, we can use the builtin `|` operator for Union types
# See PEP 604: https://peps.python.org/pep-0604
lowerCAmelCase__						:       List[Any]										=						sys.version_info >= (3, 10)




def 	_a       (				__lowerCAmelCase		:      Optional[int]=None   ,							__lowerCAmelCase		:      Union[str, Any]=None     ):

		"""simple docstring"""

		return field(default_factory=lambda: default   ,							metadata=__lowerCAmelCase     )




@dataclass
class     a			:






						"""simple docstring"""




						__UpperCAmelCase			     =    42
						__UpperCAmelCase			     =    42
						__UpperCAmelCase			     =    42
						__UpperCAmelCase			     =    42





@dataclass
class     a			:






						"""simple docstring"""




						__UpperCAmelCase			     =    42
						__UpperCAmelCase			     =    field(default="""toto"""			,			metadata={"""help""": """help message"""}       )





@dataclass
class     a			:






						"""simple docstring"""




						__UpperCAmelCase			     =    False
						__UpperCAmelCase			     =    True
						__UpperCAmelCase			     =    None





class     a			(				UpperCamelCase__       ):






						"""simple docstring"""




						__UpperCAmelCase			     =    """titi"""
						__UpperCAmelCase			     =    """toto"""





class     a			(				UpperCamelCase__       ):






						"""simple docstring"""




						__UpperCAmelCase			     =    """titi"""
						__UpperCAmelCase			     =    """toto"""
						__UpperCAmelCase			     =    42





@dataclass
class     a			:






						"""simple docstring"""




						__UpperCAmelCase			     =    "toto"







						def       __magic_name__							(							self					:      int  ):



								'''simple docstring'''



								snake_case__						:       List[str]       						=  BasicEnum(self.foo  )





@dataclass
class     a			:






						"""simple docstring"""




						__UpperCAmelCase			     =    "toto"







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



								'''simple docstring'''



								snake_case__						:       Optional[int]       						=  MixedTypeEnum(self.foo  )





@dataclass
class     a			:






						"""simple docstring"""




						__UpperCAmelCase			     =    None
						__UpperCAmelCase			     =    field(default=UpperCamelCase__			,			metadata={"""help""": """help message"""}       )
						__UpperCAmelCase			     =    None
						__UpperCAmelCase			     =    list_field(default=[]       )
						__UpperCAmelCase			     =    list_field(default=[]       )





@dataclass
class     a			:






						"""simple docstring"""




						__UpperCAmelCase			     =    list_field(default=[]       )
						__UpperCAmelCase			     =    list_field(default=[1, 2, 3]       )
						__UpperCAmelCase			     =    list_field(default=["""Hallo""", """Bonjour""", """Hello"""]       )
						__UpperCAmelCase			     =    list_field(default=[0.1, 0.2, 0.3]       )





@dataclass
class     a			:






						"""simple docstring"""




						__UpperCAmelCase			     =    field()
						__UpperCAmelCase			     =    field()
						__UpperCAmelCase			     =    field()







						def       __magic_name__							(							self					:      str  ):



								'''simple docstring'''



								snake_case__						:       List[str]       						=  BasicEnum(self.required_enum  )





@dataclass
class     a			:






						"""simple docstring"""




						__UpperCAmelCase			     =    42
						__UpperCAmelCase			     =    field()
						__UpperCAmelCase			     =    None
						__UpperCAmelCase			     =    field(default="""toto"""			,			metadata={"""help""": """help message"""}       )
						__UpperCAmelCase			     =    list_field(default=["""Hallo""", """Bonjour""", """Hello"""]       )


if is_python_no_less_than_3_10:




					@dataclass
					class     a			:






											"""simple docstring"""




											__UpperCAmelCase			     =    False
											__UpperCAmelCase			     =    True
											__UpperCAmelCase			     =    None





					@dataclass
					class     a			:






											"""simple docstring"""




											__UpperCAmelCase			     =    None
											__UpperCAmelCase			     =    field(default=UpperCamelCase__			,			metadata={"""help""": """help message"""}       )
											__UpperCAmelCase			     =    None
											__UpperCAmelCase			     =    list_field(default=[]       )
											__UpperCAmelCase			     =    list_field(default=[]       )





class     a			(				unittest.TestCase       ):






						"""simple docstring"""




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



								'''simple docstring'''



								self.assertEqual(len(a._actions  )			,			len(b._actions  )  )
								for x, y in zip(a._actions			,			b._actions  ):
										snake_case__						:       Optional[int]       						=  {k: v for k, v in vars(snake_case_  ).items() if k != '''container'''}
										snake_case__						:       Any       						=  {k: v for k, v in vars(snake_case_  ).items() if k != '''container'''}

										# Choices with mixed type have custom function as "type"
										# So we need to compare results directly for equality
										if xx.get('''choices'''			,			snake_case_  ) and yy.get('''choices'''			,			snake_case_  ):
												for expected_choice in yy["choices"] + xx["choices"]:
														self.assertEqual(xx['''type'''](snake_case_  )			,			yy['''type'''](snake_case_  )  )
												del xx["type"], yy["type"]

										self.assertEqual(snake_case_			,			snake_case_  )







						def       __magic_name__							(							self					:      Optional[int]  ):



								'''simple docstring'''



								snake_case__						:       Union[str, Any]       						=  HfArgumentParser(snake_case_  )

								snake_case__						:       Any       						=  argparse.ArgumentParser()
								expected.add_argument('''--foo'''			,			type=snake_case_			,			required=snake_case_  )
								expected.add_argument('''--bar'''			,			type=snake_case_			,			required=snake_case_  )
								expected.add_argument('''--baz'''			,			type=snake_case_			,			required=snake_case_  )
								expected.add_argument('''--flag'''			,			type=snake_case_			,			default=snake_case_			,			const=snake_case_			,			nargs='''?'''  )
								self.argparsersEqual(snake_case_			,			snake_case_  )

								snake_case__						:       Any       						=  ['''--foo''', '''1''', '''--baz''', '''quux''', '''--bar''', '''0.5''']
								((snake_case__       )						,              )						:       Dict       						=  parser.parse_args_into_dataclasses(snake_case_			,			look_for_args_file=snake_case_  )
								self.assertFalse(example.flag  )







						def       __magic_name__							(							self					:      str  ):



								'''simple docstring'''



								snake_case__						:       Optional[Any]       						=  HfArgumentParser(snake_case_  )

								snake_case__						:       Tuple       						=  argparse.ArgumentParser()
								expected.add_argument('''--foo'''			,			default=4_2			,			type=snake_case_  )
								expected.add_argument('''--baz'''			,			default='''toto'''			,			type=snake_case_			,			help='''help message'''  )
								self.argparsersEqual(snake_case_			,			snake_case_  )







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



								'''simple docstring'''



								snake_case__						:       List[str]       						=  argparse.ArgumentParser()
								expected.add_argument('''--foo'''			,			type=snake_case_			,			default=snake_case_			,			const=snake_case_			,			nargs='''?'''  )
								expected.add_argument('''--baz'''			,			type=snake_case_			,			default=snake_case_			,			const=snake_case_			,			nargs='''?'''  )
								# A boolean no_* argument always has to come after its "default: True" regular counter-part
								# and its default must be set to False
								expected.add_argument('''--no_baz'''			,			action='''store_false'''			,			default=snake_case_			,			dest='''baz'''  )
								expected.add_argument('''--opt'''			,			type=snake_case_			,			default=snake_case_  )

								snake_case__						:       Union[str, Any]       						=  [WithDefaultBoolExample]
								if is_python_no_less_than_3_10:
										dataclass_types.append(snake_case_  )

								for dataclass_type in dataclass_types:
										snake_case__						:       Dict       						=  HfArgumentParser(snake_case_  )
										self.argparsersEqual(snake_case_			,			snake_case_  )

										snake_case__						:       str       						=  parser.parse_args([]  )
										self.assertEqual(snake_case_			,			Namespace(foo=snake_case_			,			baz=snake_case_			,			opt=snake_case_  )  )

										snake_case__						:       int       						=  parser.parse_args(['''--foo''', '''--no_baz''']  )
										self.assertEqual(snake_case_			,			Namespace(foo=snake_case_			,			baz=snake_case_			,			opt=snake_case_  )  )

										snake_case__						:       str       						=  parser.parse_args(['''--foo''', '''--baz''']  )
										self.assertEqual(snake_case_			,			Namespace(foo=snake_case_			,			baz=snake_case_			,			opt=snake_case_  )  )

										snake_case__						:       Any       						=  parser.parse_args(['''--foo''', '''True''', '''--baz''', '''True''', '''--opt''', '''True''']  )
										self.assertEqual(snake_case_			,			Namespace(foo=snake_case_			,			baz=snake_case_			,			opt=snake_case_  )  )

										snake_case__						:       str       						=  parser.parse_args(['''--foo''', '''False''', '''--baz''', '''False''', '''--opt''', '''False''']  )
										self.assertEqual(snake_case_			,			Namespace(foo=snake_case_			,			baz=snake_case_			,			opt=snake_case_  )  )







						def       __magic_name__							(							self					:      List[Any]  ):



								'''simple docstring'''



								snake_case__						:       str       						=  HfArgumentParser(snake_case_  )

								snake_case__						:       List[str]       						=  argparse.ArgumentParser()
								expected.add_argument(
								    '''--foo'''			,			default='''toto'''			,			choices=['''titi''', '''toto''', 4_2]			,			type=make_choice_type_function(['''titi''', '''toto''', 4_2]  )			,			)
								self.argparsersEqual(snake_case_			,			snake_case_  )

								snake_case__						:       str       						=  parser.parse_args([]  )
								self.assertEqual(args.foo			,			'''toto'''  )
								snake_case__						:       Any       						=  parser.parse_args_into_dataclasses([]  )[0]
								self.assertEqual(enum_ex.foo			,			MixedTypeEnum.toto  )

								snake_case__						:       str       						=  parser.parse_args(['''--foo''', '''titi''']  )
								self.assertEqual(args.foo			,			'''titi'''  )
								snake_case__						:       Any       						=  parser.parse_args_into_dataclasses(['''--foo''', '''titi''']  )[0]
								self.assertEqual(enum_ex.foo			,			MixedTypeEnum.titi  )

								snake_case__						:       int       						=  parser.parse_args(['''--foo''', '''42''']  )
								self.assertEqual(args.foo			,			4_2  )
								snake_case__						:       Tuple       						=  parser.parse_args_into_dataclasses(['''--foo''', '''42''']  )[0]
								self.assertEqual(enum_ex.foo			,			MixedTypeEnum.fourtytwo  )







						def       __magic_name__							(							self					:      List[str]  ):



								'''simple docstring'''



								@dataclass
								class     a			:






														"""simple docstring"""




														__UpperCAmelCase			     =    "toto"





								snake_case__						:       List[str]       						=  HfArgumentParser(snake_case_  )

								snake_case__						:       Optional[int]       						=  argparse.ArgumentParser()
								expected.add_argument(
								    '''--foo'''			,			default='''toto'''			,			choices=('''titi''', '''toto''', 4_2)			,			type=make_choice_type_function(['''titi''', '''toto''', 4_2]  )			,			)
								self.argparsersEqual(snake_case_			,			snake_case_  )

								snake_case__						:       Optional[int]       						=  parser.parse_args([]  )
								self.assertEqual(args.foo			,			'''toto'''  )

								snake_case__						:       List[Any]       						=  parser.parse_args(['''--foo''', '''titi''']  )
								self.assertEqual(args.foo			,			'''titi'''  )

								snake_case__						:       Union[str, Any]       						=  parser.parse_args(['''--foo''', '''42''']  )
								self.assertEqual(args.foo			,			4_2  )







						def       __magic_name__							(							self					:      str  ):



								'''simple docstring'''



								snake_case__						:       Optional[int]       						=  HfArgumentParser(snake_case_  )

								snake_case__						:       Tuple       						=  argparse.ArgumentParser()
								expected.add_argument('''--foo_int'''			,			nargs='''+'''			,			default=[]			,			type=snake_case_  )
								expected.add_argument('''--bar_int'''			,			nargs='''+'''			,			default=[1, 2, 3]			,			type=snake_case_  )
								expected.add_argument('''--foo_str'''			,			nargs='''+'''			,			default=['''Hallo''', '''Bonjour''', '''Hello''']			,			type=snake_case_  )
								expected.add_argument('''--foo_float'''			,			nargs='''+'''			,			default=[0.1, 0.2, 0.3]			,			type=snake_case_  )

								self.argparsersEqual(snake_case_			,			snake_case_  )

								snake_case__						:       str       						=  parser.parse_args([]  )
								self.assertEqual(
								    snake_case_			,			Namespace(foo_int=[]			,			bar_int=[1, 2, 3]			,			foo_str=['''Hallo''', '''Bonjour''', '''Hello''']			,			foo_float=[0.1, 0.2, 0.3]  )			,			)

								snake_case__						:       List[str]       						=  parser.parse_args('''--foo_int 1 --bar_int 2 3 --foo_str a b c --foo_float 0.1 0.7'''.split()  )
								self.assertEqual(snake_case_			,			Namespace(foo_int=[1]			,			bar_int=[2, 3]			,			foo_str=['''a''', '''b''', '''c''']			,			foo_float=[0.1, 0.7]  )  )







						def       __magic_name__							(							self					:      Optional[int]  ):



								'''simple docstring'''



								snake_case__						:       Union[str, Any]       						=  argparse.ArgumentParser()
								expected.add_argument('''--foo'''			,			default=snake_case_			,			type=snake_case_  )
								expected.add_argument('''--bar'''			,			default=snake_case_			,			type=snake_case_			,			help='''help message'''  )
								expected.add_argument('''--baz'''			,			default=snake_case_			,			type=snake_case_  )
								expected.add_argument('''--ces'''			,			nargs='''+'''			,			default=[]			,			type=snake_case_  )
								expected.add_argument('''--des'''			,			nargs='''+'''			,			default=[]			,			type=snake_case_  )

								snake_case__						:       List[Any]       						=  [OptionalExample]
								if is_python_no_less_than_3_10:
										dataclass_types.append(snake_case_  )

								for dataclass_type in dataclass_types:
										snake_case__						:       str       						=  HfArgumentParser(snake_case_  )

										self.argparsersEqual(snake_case_			,			snake_case_  )

										snake_case__						:       Any       						=  parser.parse_args([]  )
										self.assertEqual(snake_case_			,			Namespace(foo=snake_case_			,			bar=snake_case_			,			baz=snake_case_			,			ces=[]			,			des=[]  )  )

										snake_case__						:       Optional[Any]       						=  parser.parse_args('''--foo 12 --bar 3.14 --baz 42 --ces a b c --des 1 2 3'''.split()  )
										self.assertEqual(snake_case_			,			Namespace(foo=1_2			,			bar=3.1_4			,			baz='''42'''			,			ces=['''a''', '''b''', '''c''']			,			des=[1, 2, 3]  )  )







						def       __magic_name__							(							self					:      Tuple  ):



								'''simple docstring'''



								snake_case__						:       List[str]       						=  HfArgumentParser(snake_case_  )

								snake_case__						:       Union[str, Any]       						=  argparse.ArgumentParser()
								expected.add_argument('''--required_list'''			,			nargs='''+'''			,			type=snake_case_			,			required=snake_case_  )
								expected.add_argument('''--required_str'''			,			type=snake_case_			,			required=snake_case_  )
								expected.add_argument(
								    '''--required_enum'''			,			type=make_choice_type_function(['''titi''', '''toto''']  )			,			choices=['''titi''', '''toto''']			,			required=snake_case_			,			)
								self.argparsersEqual(snake_case_			,			snake_case_  )







						def       __magic_name__							(							self					:      int  ):



								'''simple docstring'''



								snake_case__						:       List[Any]       						=  HfArgumentParser(snake_case_  )

								snake_case__						:       List[str]       						=  argparse.ArgumentParser()
								expected.add_argument('''--foo'''			,			type=snake_case_			,			required=snake_case_  )
								expected.add_argument(
								    '''--required_enum'''			,			type=make_choice_type_function(['''titi''', '''toto''']  )			,			choices=['''titi''', '''toto''']			,			required=snake_case_			,			)
								expected.add_argument('''--opt'''			,			type=snake_case_			,			default=snake_case_  )
								expected.add_argument('''--baz'''			,			default='''toto'''			,			type=snake_case_			,			help='''help message'''  )
								expected.add_argument('''--foo_str'''			,			nargs='''+'''			,			default=['''Hallo''', '''Bonjour''', '''Hello''']			,			type=snake_case_  )
								self.argparsersEqual(snake_case_			,			snake_case_  )







						def       __magic_name__							(							self					:      Optional[Any]  ):



								'''simple docstring'''



								snake_case__						:       Dict       						=  HfArgumentParser(snake_case_  )

								snake_case__						:       str       						=  {
								    '''foo''': 1_2,
								    '''bar''': 3.1_4,
								    '''baz''': '''42''',
								    '''flag''': True,
								}

								snake_case__						:       Union[str, Any]       						=  parser.parse_dict(snake_case_  )[0]
								snake_case__						:       Dict       						=  BasicExample(**snake_case_  )
								self.assertEqual(snake_case_			,			snake_case_  )







						def       __magic_name__							(							self					:      str  ):



								'''simple docstring'''



								snake_case__						:       List[str]       						=  HfArgumentParser(snake_case_  )

								snake_case__						:       Optional[Any]       						=  {
								    '''foo''': 1_2,
								    '''bar''': 3.1_4,
								    '''baz''': '''42''',
								    '''flag''': True,
								    '''extra''': 4_2,
								}

								self.assertRaises(snake_case_			,			parser.parse_dict			,			snake_case_			,			allow_extra_keys=snake_case_  )







						def       __magic_name__							(							self					:      List[Any]  ):



								'''simple docstring'''



								snake_case__						:       List[Any]       						=  HfArgumentParser(snake_case_  )

								snake_case__						:       Dict       						=  {
								    '''foo''': 1_2,
								    '''bar''': 3.1_4,
								    '''baz''': '''42''',
								    '''flag''': True,
								}
								with tempfile.TemporaryDirectory() as tmp_dir:
										snake_case__						:       Any       						=  os.path.join(snake_case_			,			'''temp_json'''  )
										os.mkdir(snake_case_  )
										with open(temp_local_path + '''.json'''			,			'''w+'''  ) as f:
												json.dump(snake_case_			,			snake_case_  )
										snake_case__						:       List[str]       						=  parser.parse_yaml_file(Path(temp_local_path + '''.json'''  )  )[0]

								snake_case__						:       Dict       						=  BasicExample(**snake_case_  )
								self.assertEqual(snake_case_			,			snake_case_  )







						def       __magic_name__							(							self					:      Optional[int]  ):



								'''simple docstring'''



								snake_case__						:       Union[str, Any]       						=  HfArgumentParser(snake_case_  )

								snake_case__						:       Any       						=  {
								    '''foo''': 1_2,
								    '''bar''': 3.1_4,
								    '''baz''': '''42''',
								    '''flag''': True,
								}
								with tempfile.TemporaryDirectory() as tmp_dir:
										snake_case__						:       List[Any]       						=  os.path.join(snake_case_			,			'''temp_yaml'''  )
										os.mkdir(snake_case_  )
										with open(temp_local_path + '''.yaml'''			,			'''w+'''  ) as f:
												yaml.dump(snake_case_			,			snake_case_  )
										snake_case__						:       Tuple       						=  parser.parse_yaml_file(Path(temp_local_path + '''.yaml'''  )  )[0]
								snake_case__						:       Optional[int]       						=  BasicExample(**snake_case_  )
								self.assertEqual(snake_case_			,			snake_case_  )







						def       __magic_name__							(							self					:      Tuple  ):



								'''simple docstring'''



								snake_case__						:       Optional[Any]       						=  HfArgumentParser(snake_case_  )
								self.assertIsNotNone(snake_case_  )






'''simple docstring'''


from collections.abc import Sequence




def 	_a       (				__lowerCAmelCase		:      Sequence[int] | None = None     ):

		"""simple docstring"""

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

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

		return ans


if __name__ == "__main__":
					import doctest

					doctest.testmod()

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



