


"""simple docstring"""



def     UpperCAmelCase    (					_lowercase   :      Union[str, Any] ,      _lowercase   :      Union[str, Any] ,      _lowercase   :      List[Any]  )	->   Optional[Any]:


	"""simple docstring"""




	lowerCAmelCase_			       = index
	lowerCAmelCase_			       = 2 * index + 1
	lowerCAmelCase_			       = 2 * index + 2
	if left_index < heap_size and unsorted[left_index] > unsorted[largest]:
		lowerCAmelCase_			       = left_index

	if right_index < heap_size and unsorted[right_index] > unsorted[largest]:
		lowerCAmelCase_			       = right_index

	if largest != index:
		lowerCAmelCase_       ,  lowerCAmelCase_			       = unsorted[index], unsorted[largest]
		heapify(_lowercase ,      _lowercase ,      _lowercase  )
def     UpperCAmelCase    (					_lowercase   :      str  )	->   Optional[Any]:


	"""simple docstring"""




	lowerCAmelCase_			       = len(_lowercase  )
	for i in range(n // 2 - 1 ,      -1 ,      -1  ):
		heapify(_lowercase ,      _lowercase ,      _lowercase  )
	for i in range(n - 1 ,      0 ,      -1  ):
		lowerCAmelCase_       ,  lowerCAmelCase_			       = unsorted[i], unsorted[0]
		heapify(_lowercase ,      0 ,      _lowercase  )
	return unsorted


if __name__ == "__main__":
		lowercase_							 =       input('Enter numbers separated by a comma:\n').strip()
		lowercase_							 =       [int(item) for item in user_input.split(',')]
		print(heap_sort(unsorted))



"""simple docstring"""



def     UpperCAmelCase    (					_lowercase   :      list[int]  )	->   int:


	"""simple docstring"""




	lowerCAmelCase_			       = len(_lowercase  )
	if n in (0, 1):
		return 0
	return sum(query * (n - i - 1) for i, query in enumerate(sorted(_lowercase  )  )  )


if __name__ == "__main__":
		import doctest

		doctest.testmod()