

'''simple docstring'''





import os
import random
import sys

from . import cryptomath_module as cryptomath
from . import rabin_miller

UpperCamelCase_    						=       3






def 				_lowerCAmelCase			(   __magic_name__						:     int						)				->  int:
						print('''Generating primitive root of p'''						)
						while True:
												lowercase :							str    		=random.randrange(3   , __magic_name__						)
												if pow(__magic_name__   , 2   , __magic_name__						) == 1:
																		continue
												if pow(__magic_name__   , __magic_name__   , __magic_name__						) == 1:
																		continue
												return g






def 				_lowerCAmelCase			(   __magic_name__						:     int						)				->  tuple[tuple[int, int, int, int], tuple[int, int]]:
						print('''Generating prime p...'''						)
						lowercase :							List[Any]    		=rabin_miller.generate_large_prime(__magic_name__						)  # select large prime number.
						lowercase :							Optional[Any]    		=primitive_root(__magic_name__						)  # one primitive root on modulo p.
						lowercase :							Tuple    		=random.randrange(3   , __magic_name__						)  # private_key -> have to be greater than 2 for safety.
						lowercase :							Any    		=cryptomath.find_mod_inverse(pow(__magic_name__   , __magic_name__   , __magic_name__						)   , __magic_name__						)

						lowercase :							Dict    		=(key_size, e_a, e_a, p)
						lowercase :							Tuple    		=(key_size, d)

						return public_key, private_key






def 				_lowerCAmelCase			(   __magic_name__						:     str   , __magic_name__						:     int						)				->  None:
						if os.path.exists(f'''{name}_pubkey.txt'''						) or os.path.exists(f'''{name}_privkey.txt'''						):
												print('''\nWARNING:'''						)
												print(
												    f'''"{name}_pubkey.txt" or "{name}_privkey.txt" already exists. \n'''
												    '''Use a different name or delete these files and re-run this program.'''						)
												sys.exit()

						lowercase		,	lowercase :							Dict    		=generate_key(__magic_name__						)
						print(f'''\nWriting public key to file {name}_pubkey.txt...'''						)
						with open(f'''{name}_pubkey.txt'''   , '''w'''						) as fo:
												fo.write(f'''{public_key[0]},{public_key[1]},{public_key[2]},{public_key[3]}'''						)

						print(f'''Writing private key to file {name}_privkey.txt...'''						)
						with open(f'''{name}_privkey.txt'''   , '''w'''						) as fo:
												fo.write(f'''{private_key[0]},{private_key[1]}'''						)






def 				_lowerCAmelCase			(   )				->  None:
						print('''Making key files...'''						)
						make_key_files('''elgamal'''   , 2048						)
						print('''Key files generation successful'''						)


if __name__ == "__main__":
							main()








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

