


"""simple docstring"""





from __future__ import annotations

from random import random




class 							snake_case							:

      '''simple docstring'''



      def __init__(							self       :      Dict						,				__lowercase       :      int | None = None ):


        '''simple docstring'''




        __UpperCAmelCase    :						Union[str, Any]       =						value
        __UpperCAmelCase    :						int       =						random()
        __UpperCAmelCase    :						Node | None       =						None
        __UpperCAmelCase    :						Node | None       =						None

      def __repr__(							self       :      Optional[int] ):


        '''simple docstring'''




        from pprint import pformat

        if self.left is None and self.right is None:
          return f'''\'{self.value}: {self.prior:.5}\''''
        else:
          return pformat(
              {f'''{self.value}: {self.prior:.5}''': (self.left, self.right)}						,				indent=1 )







      def __str__(							self       :      Any ):


        '''simple docstring'''




        __UpperCAmelCase    :						Tuple       =						str(self.value ) + ''' '''
        __UpperCAmelCase    :						str       =						str(self.left or '''''' )
        __UpperCAmelCase    :						Dict       =						str(self.right or '''''' )
        return value + left + right


def       lowerCamelCase_       (   UpperCAmelCase_  ,			UpperCAmelCase_  )						->tuple[Node | None, Node | None]:





  """simple docstring"""


  if root is None:  # None tree is split into 2 Nones
    return None, None
  elif root.value is None:
    return None, None
  else:
    if value < root.value:
      __UpperCAmelCase    :						List[Any]       =						split(root.left  ,			UpperCAmelCase_  )
      return left, root
    else:
      __UpperCAmelCase    :						str       =						split(root.right  ,			UpperCAmelCase_  )
      return root, right


def       lowerCamelCase_       (   UpperCAmelCase_  ,			UpperCAmelCase_  )						->Node | None:





  """simple docstring"""


  if (not left) or (not right):  # If one node is None, return the other
    return left or right
  elif left.prior < right.prior:
    __UpperCAmelCase    :						Dict       =						merge(left.right  ,			UpperCAmelCase_  )
    return left
  else:
    __UpperCAmelCase    :						str       =						merge(UpperCAmelCase_  ,			right.left  )
    return right


def       lowerCamelCase_       (   UpperCAmelCase_  ,			UpperCAmelCase_  )						->Node | None:





  """simple docstring"""


  __UpperCAmelCase    :						Dict       =						Node(UpperCAmelCase_  )
  __UpperCAmelCase    :						int       =						split(UpperCAmelCase_  ,			UpperCAmelCase_  )
  return merge(merge(UpperCAmelCase_  ,			UpperCAmelCase_  )  ,			UpperCAmelCase_  )


def       lowerCamelCase_       (   UpperCAmelCase_  ,			UpperCAmelCase_  )						->Node | None:





  """simple docstring"""


  __UpperCAmelCase    :						Any       =						split(UpperCAmelCase_  ,			value - 1  )
  __UpperCAmelCase    :						List[str]       =						split(UpperCAmelCase_  ,			UpperCAmelCase_  )
  return merge(UpperCAmelCase_  ,			UpperCAmelCase_  )


def       lowerCamelCase_       (   UpperCAmelCase_  )						->None:





  """simple docstring"""


  if not root:  # None
    return
  else:
    inorder(root.left  )
    print(root.value  ,			end=''','''  )
    inorder(root.right  )


def       lowerCamelCase_       (   UpperCAmelCase_  ,			UpperCAmelCase_  )						->Node | None:





  """simple docstring"""


  for arg in args.split():
    if arg[0] == "+":
      __UpperCAmelCase    :						Optional[int]       =						insert(UpperCAmelCase_  ,			int(arg[1:]  )  )

    elif arg[0] == "-":
      __UpperCAmelCase    :						List[str]       =						erase(UpperCAmelCase_  ,			int(arg[1:]  )  )

    else:
      print('''Unknown command'''  )

  return root


def       lowerCamelCase_       (   )						->None:





  """simple docstring"""


  __UpperCAmelCase    :						Any       =						None
  print(
      '''enter numbers to create a tree, + value to add value into treap, '''
      '''- value to erase all nodes with value. \'q\' to quit. '''  )

  __UpperCAmelCase    :						List[Any]       =						input()
  while args != "q":
    __UpperCAmelCase    :						List[Any]       =						interact_treap(UpperCAmelCase_  ,			UpperCAmelCase_  )
    print(UpperCAmelCase_  )
    __UpperCAmelCase    :						Optional[Any]       =						input()

  print('''good by!'''  )


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  main()






"""simple docstring"""





def       lowerCamelCase_       (   UpperCAmelCase_ = 10_00  )						->int:





  """simple docstring"""


  return sum(2 * a * ((a - 1) // 2) for a in range(3  ,			n + 1  )  )


if __name__ == "__main__":
  print(solution())