


'''simple docstring'''







class A__	:






      def __init__(			self      :List[Any]					,						SCREAMING_SNAKE_CASE      :int     )	-> Tuple:




             '''simple docstring'''
             _a   :			Tuple					 =val
             # Number of nodes in left subtree
             _a   :			Optional[int]					 =0
             _a   :			int					 =None
             _a   :			List[str]					 =None
             _a   :			Optional[int]					 =None






      def __UpperCAmelCase	(			self      :Dict					,						SCREAMING_SNAKE_CASE      :Optional[int]     )	-> str:




             '''simple docstring'''
             assert self.left_tree_size == other.left_tree_size, "Unequal Sizes of Blocks"

             if self.val < other.val:
                    _a   :			Optional[int]					 =self.right
                    _a   :			Optional[int]					 =None
                    if self.right:
                           _a   :			Optional[Any]					 =other
                    _a   :			Dict					 =other
                    _a   :			int					 =self.left_tree_size * 2 + 1
                    return self
             else:
                    _a   :			Optional[Any]					 =other.right
                    _a   :			str					 =None
                    if other.right:
                           _a   :			int					 =self
                    _a   :			List[Any]					 =self
                    _a   :			List[Any]					 =other.left_tree_size * 2 + 1
                    return other







class A__	:






      def __init__(			self      :Optional[Any]					,						SCREAMING_SNAKE_CASE      :List[Any]=None					,						SCREAMING_SNAKE_CASE      :List[Any]=None					,						SCREAMING_SNAKE_CASE      :int=0     )	-> Optional[int]:




             '''simple docstring'''
             _a   :			Dict					 =heap_size
             _a   :			Union[str, Any]					 =bottom_root
             _a   :			Tuple					 =min_node






      def __UpperCAmelCase	(			self      :str					,						SCREAMING_SNAKE_CASE      :List[Any]     )	-> Optional[int]:




             '''simple docstring'''

             # Empty heaps corner cases
             if other.size == 0:
                    return None
             if self.size == 0:
                    _a   :			Tuple					 =other.size
                    _a   :			Optional[Any]					 =other.bottom_root
                    _a   :			int					 =other.min_node
                    return None
             # Update size
             _a   :			Dict					 =self.size + other.size

             # Update min.node
             if self.min_node.val > other.min_node.val:
                    _a   :			List[Any]					 =other.min_node
             # Merge

             # Order roots by left_subtree_size
             _a   :			Tuple					 =[]
             _a ,   _a   :			Dict					 =self.bottom_root, other.bottom_root
             while i or j:
                    if i and ((not j) or i.left_tree_size < j.left_tree_size):
                           combined_roots_list.append((i, True)     )
                           _a   :			Union[str, Any]					 =i.parent
                    else:
                           combined_roots_list.append((j, False)     )
                           _a   :			Optional[Any]					 =j.parent
        # Insert links between them
             for i in range(len(SCREAMING_SNAKE_CASE     ) - 1     ):
                    if combined_roots_list[i][1] != combined_roots_list[i + 1][1]:
                           _a   :			Union[str, Any]					 =combined_roots_list[i + 1][0]
                           _a   :			List[str]					 =combined_roots_list[i][0]
        # Consecutively merge roots with same left_tree_size
             _a   :			Optional[int]					 =combined_roots_list[0][0]
             while i.parent:
                    if (
                        (i.left_tree_size == i.parent.left_tree_size) and (not i.parent.parent)
                    ) or (
                        i.left_tree_size == i.parent.left_tree_size
                        and i.left_tree_size != i.parent.parent.left_tree_size
                    ):
                           # Neighbouring Nodes
                           _a   :			Optional[int]					 =i.left
                           _a   :			List[Any]					 =i.parent.parent

                           # Merging trees
                           _a   :			List[Any]					 =i.merge_trees(i.parent     )

                           # Updating links
                           _a   :			Any					 =previous_node
                           _a   :			int					 =next_node
                           if previous_node:
                                  _a   :			Optional[Any]					 =i
                           if next_node:
                                  _a   :			List[Any]					 =i
                    else:
                           _a   :			int					 =i.parent
        # Updating self.bottom_root
             while i.left:
                    _a   :			Any					 =i.left
             _a   :			Dict					 =i

             # Update other
             _a   :			Optional[Any]					 =self.size
             _a   :			str					 =self.bottom_root
             _a   :			Tuple					 =self.min_node

             # Return the merged heap
             return self






      def __UpperCAmelCase	(			self      :int					,						SCREAMING_SNAKE_CASE      :Optional[int]     )	-> List[str]:




             '''simple docstring'''
             if self.size == 0:
                    _a   :			Optional[Any]					 =Node(SCREAMING_SNAKE_CASE     )
                    _a   :			Tuple					 =1
                    _a   :			List[str]					 =self.bottom_root
             else:
                    # Create new node
                    _a   :			Any					 =Node(SCREAMING_SNAKE_CASE     )

                    # Update size
                    self.size += 1

                    # update min_node
                    if val < self.min_node.val:
                           _a   :			List[str]					 =new_node
                    # Put new_node as a bottom_root in heap
                    _a   :			List[str]					 =new_node
                    _a   :			List[str]					 =self.bottom_root
                    _a   :			List[Any]					 =new_node

                    # Consecutively merge roots with same left_tree_size
                    while (
                        self.bottom_root.parent
                        and self.bottom_root.left_tree_size
                        == self.bottom_root.parent.left_tree_size
                    ):
                           # Next node
                           _a   :			str					 =self.bottom_root.parent.parent

                           # Merge
                           _a   :			Optional[int]					 =self.bottom_root.merge_trees(self.bottom_root.parent     )

                           # Update Links
                           _a   :			Union[str, Any]					 =next_node
                           _a   :			str					 =None
                           if next_node:
                                  _a   :			Union[str, Any]					 =self.bottom_root






      def __UpperCAmelCase	(			self      :Union[str, Any]     )	-> Union[str, Any]:




             '''simple docstring'''
             return self.min_node.val






      def __UpperCAmelCase	(			self      :Union[str, Any]     )	-> Optional[Any]:




             '''simple docstring'''
             return self.size == 0






      def __UpperCAmelCase	(			self      :Dict     )	-> str:




             '''simple docstring'''
             _a   :			List[str]					 =self.min_node.val

             # Last element in heap corner case
             if self.size == 1:
                    # Update size
                    _a   :			Tuple					 =0

                    # Update bottom root
                    _a   :			List[Any]					 =None

                    # Update min_node
                    _a   :			List[str]					 =None

                    return min_value
             # No right subtree corner case
             # The structure of the tree implies that this should be the bottom root
             # and there is at least one other root
             if self.min_node.right is None:
                    # Update size
                    self.size -= 1

                    # Update bottom root
                    _a   :			Any					 =self.bottom_root.parent
                    _a   :			Any					 =None

                    # Update min_node
                    _a   :			Optional[int]					 =self.bottom_root
                    _a   :			List[Any]					 =self.bottom_root.parent
                    while i:
                           if i.val < self.min_node.val:
                                  _a   :			List[str]					 =i
                           _a   :			List[str]					 =i.parent
                    return min_value
             # General case
             # Find the BinomialHeap of the right subtree of min_node
             _a   :			List[Any]					 =self.min_node.right
             _a   :			Optional[Any]					 =None
             _a   :			Tuple					 =bottom_of_new
             _a   :			Any					 =1

             # Size, min_node and bottom_root
             while bottom_of_new.left:
                    _a   :			Optional[int]					 =size_of_new * 2 + 1
                    _a   :			Optional[Any]					 =bottom_of_new.left
                    if bottom_of_new.val < min_of_new.val:
                           _a   :			str					 =bottom_of_new
        # Corner case of single root on top left path
             if (not self.min_node.left) and (not self.min_node.parent):
                    _a   :			Union[str, Any]					 =size_of_new
                    _a   :			List[Any]					 =bottom_of_new
                    _a   :			str					 =min_of_new
                    # print("Single root, multiple nodes case")
                    return min_value
             # Remaining cases
             # Construct heap of right subtree
             _a   :			str					 =BinomialHeap(
                 bottom_root=SCREAMING_SNAKE_CASE					,						min_node=SCREAMING_SNAKE_CASE					,						heap_size=SCREAMING_SNAKE_CASE     )

             # Update size
             _a   :			Optional[int]					 =self.size - 1 - size_of_new

             # Neighbour nodes
             _a   :			Dict					 =self.min_node.left
             _a   :			str					 =self.min_node.parent

             # Initialize new bottom_root and min_node
             _a   :			Optional[Any]					 =previous_node or next_node
             _a   :			List[str]					 =next_node

             # Update links of previous_node and search below for new min_node and
             # bottom_root
             if previous_node:
                    _a   :			int					 =next_node

                    # Update bottom_root and search for min_node below
                    _a   :			Optional[int]					 =previous_node
                    _a   :			Any					 =previous_node
                    while self.bottom_root.left:
                           _a   :			Optional[int]					 =self.bottom_root.left
                           if self.bottom_root.val < self.min_node.val:
                                  _a   :			Tuple					 =self.bottom_root
             if next_node:
                    _a   :			Any					 =previous_node

                    # Search for new min_node above min_node
                    _a   :			int					 =next_node
                    while i:
                           if i.val < self.min_node.val:
                                  _a   :			Optional[int]					 =i
                           _a   :			Tuple					 =i.parent
        # Merge heaps
             self.merge_heaps(SCREAMING_SNAKE_CASE     )

             return min_value






      def __UpperCAmelCase	(			self      :Union[str, Any]     )	-> Any:




             '''simple docstring'''
             _a   :			Optional[Any]					 =self.bottom_root
             while top_root.parent:
                    _a   :			List[str]					 =top_root.parent
             # preorder
             _a   :			Dict					 =[]
             self.__traversal(SCREAMING_SNAKE_CASE					,						SCREAMING_SNAKE_CASE     )
             return heap_pre_order






      def __UpperCAmelCase	(			self      :List[str]					,						SCREAMING_SNAKE_CASE      :Optional[int]					,						SCREAMING_SNAKE_CASE      :Optional[Any]					,						SCREAMING_SNAKE_CASE      :Dict=0     )	-> Any:




             '''simple docstring'''
             if curr_node:
                    preorder.append((curr_node.val, level)     )
                    self.__traversal(curr_node.left					,						SCREAMING_SNAKE_CASE					,						level + 1     )
                    self.__traversal(curr_node.right					,						SCREAMING_SNAKE_CASE					,						level + 1     )
             else:
                    preorder.append(("""#""", level)     )






      def __str__(			self      :Tuple     )	-> Any:




             '''simple docstring'''
             if self.is_empty():
                    return ""
             _a   :			Union[str, Any]					 =self.pre_order()

             return "\n".join(("""-""" * level + str(SCREAMING_SNAKE_CASE     )) for value, level in preorder_heap     )


# Unit Tests
if __name__ == "__main__":
   import doctest

   doctest.testmod()






'''simple docstring'''







def      SCREAMING_SNAKE_CASE_ (  _UpperCAmelCase     :     Union[str, Any]  )  ->      int:
       _a   :			List[str]					 =[701, 301, 132, 57, 23, 10, 4, 1]
       for gap in gaps:
              for i in range(_UpperCAmelCase   ,len(_UpperCAmelCase  )  ):
                     _a   :			Tuple					 =collection[i]
                     _a   :			Optional[Any]					 =i
                     while j >= gap and collection[j - gap] > insert_value:
                            _a   :			Union[str, Any]					 =collection[j - gap]
                            j -= gap
                     if j != i:
                            _a   :			Union[str, Any]					 =insert_value
       return collection


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

   testmod()
   A__:   int    =	input('''Enter numbers separated by a comma:\n''').strip()
   A__:   Optional[Any]    =	[int(item) for item in user_input.split(''',''')]
   print(shell_sort(unsorted))


