





from __future__ import annotations

SCREAMING_SNAKE_CASE_						   =       [-1_0, -5, 0, 5, 5.1, 1_1, 1_3, 2_1, 3, 4, -2_1, -1_0, -5, -1, 0]
SCREAMING_SNAKE_CASE_						   =       [-5, 0, 5, 5.1, 1_1, 1_3, 2_1, -1, 4, -1, -1_0, -5, -1, 0, -1]



def    __lowercase   (      _SCREAMING_SNAKE_CASE	) ->   Tuple:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE		=						[]
      SCREAMING_SNAKE_CASE		=						len(_A	)

      for i in range(_A	):
            SCREAMING_SNAKE_CASE		=						-1
            for j in range(i + 1 ,						_A	):
                  if arr[i] < arr[j]:
                        SCREAMING_SNAKE_CASE		=						arr[j]
                        break
            result.append(_A	)
      return result



def    __lowercase   (      _SCREAMING_SNAKE_CASE	) ->   List[Any]:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE		=						[]
      for i, outer in enumerate(_A	):
            SCREAMING_SNAKE_CASE		=						-1
            for inner in arr[i + 1 :]:
                  if outer < inner:
                        SCREAMING_SNAKE_CASE		=						inner
                        break
            result.append(_A	)
      return result



def    __lowercase   (      _SCREAMING_SNAKE_CASE	) ->   Dict:


      '''simple docstring'''


      SCREAMING_SNAKE_CASE		=						len(_A	)
      SCREAMING_SNAKE_CASE		=						[]
      SCREAMING_SNAKE_CASE		=						[-1] * arr_size

      for index in reversed(range(_A	)	):
            if stack:
                  while stack[-1] <= arr[index]:
                        stack.pop()
                        if not stack:
                              break
            if stack:
                  SCREAMING_SNAKE_CASE		=						stack[-1]
            stack.append(arr[index]	)
      return result


if __name__ == "__main__":
      from doctest import testmod
      from timeit import timeit

      testmod()
      print(next_greatest_element_slow(arr))
      print(next_greatest_element_fast(arr))
      print(next_greatest_element(arr))

      SCREAMING_SNAKE_CASE_						   =       (
          """from __main__ import arr, next_greatest_element_slow, """
          """next_greatest_element_fast, next_greatest_element"""
      )
      print(
          """next_greatest_element_slow():""",
          timeit("""next_greatest_element_slow(arr)""", setup=setup),
      )
      print(
          """next_greatest_element_fast():""",
          timeit("""next_greatest_element_fast(arr)""", setup=setup),
      )
      print(
          """     next_greatest_element():""",
          timeit("""next_greatest_element(arr)""", setup=setup),
      )








def __UpperCamelCase			(       _A  ):
						if not numbers:
												return 0

						if not isinstance(_A ,  (list, tuple)  ) or not all(
						    isinstance(_A ,  _A  ) for number in numbers  ):
												raise ValueError('''numbers must be an iterable of integers'''  )

						lowerCAmelCase_      			=  lowerCAmelCase_      			=  lowerCAmelCase_      			=  numbers[0]

						for i in range(1 ,  len(_A  )  ):
												# update the maximum and minimum subarray products
												lowerCAmelCase_      			=  numbers[i]
												if number < 0:
																		lowerCAmelCase_			,					lowerCAmelCase_      			=  min_till_now, max_till_now
												lowerCAmelCase_      			=  max(_A ,  max_till_now * number  )
												lowerCAmelCase_      			=  min(_A ,  min_till_now * number  )

												# update the maximum product found till now
												lowerCAmelCase_      			=  max(_A ,  _A  )

						return max_prod




