




class  _lowerCAmelCase     :

      def __init__(   self      ,				__UpperCAmelCase		):
        lowerCAmelCase__				:  Union[str, Any]		       =     n
        lowerCAmelCase__				:  Dict		       =     [None] * self.n
        lowerCAmelCase__				:  str		       =     0  # index of the first element
        lowerCAmelCase__				:  List[str]		       =     0
        lowerCAmelCase__				:  Union[str, Any]		       =     0

      def __len__(   self		):
        return self.size

      def 	__magic_name__(   self		):
        return self.size == 0

      def 	__magic_name__(   self		):
        return False if self.is_empty() else self.array[self.front]

      def 	__magic_name__(   self      ,				__UpperCAmelCase		):
        if self.size >= self.n:
          raise Exception('''QUEUE IS FULL'''		)

        lowerCAmelCase__				:  List[Any]		       =     data
        lowerCAmelCase__				:  List[str]		       =     (self.rear + 1) % self.n
        self.size += 1
        return self







      def 	__magic_name__(   self		):
        if self.size == 0:
          raise Exception('''UNDERFLOW'''		)

        lowerCAmelCase__				:  Dict		       =     self.array[self.front]
        lowerCAmelCase__				:  Dict		       =     None
        lowerCAmelCase__				:  Dict		       =     (self.front + 1) % self.n
        self.size -= 1
        return temp







from __future__ import annotations



def      __lowerCAmelCase			(					UpperCamelCase      )     ->	list[int]:  # This function is recursive
  lowerCAmelCase__				:  Tuple		       =     len(UpperCamelCase      )
  # If the array contains only one element, we return it (it's the stop condition of
  # recursion)
  if array_length <= 1:
    return array
    # Else
  lowerCAmelCase__				:  Optional[int]		       =     array[0]
  lowerCAmelCase__				:  Union[str, Any]		       =     False
  lowerCAmelCase__				:  List[str]		       =     1
  lowerCAmelCase__				:  list[int]		       =     []
  while not is_found and i < array_length:
    if array[i] < pivot:
      lowerCAmelCase__				:  List[Any]		       =     True
      lowerCAmelCase__				:  Optional[int]		       =     [element for element in array[i:] if element >= array[i]]
      lowerCAmelCase__				:  Any		       =     longest_subsequence(UpperCamelCase      )
      if len(UpperCamelCase      ) > len(UpperCamelCase      ):
        lowerCAmelCase__				:  Optional[int]		       =     temp_array
    else:
      i += 1

  lowerCAmelCase__				:  Optional[Any]		       =     [element for element in array[1:] if element >= pivot]
  lowerCAmelCase__				:  List[Any]		       =     [pivot, *longest_subsequence(UpperCamelCase      )]
  if len(UpperCamelCase      ) > len(UpperCamelCase      ):
    return temp_array
  else:
    return longest_subseq


if __name__ == "__main__":
     import doctest

     doctest.testmod()

