

"""simple docstring"""




import sys
def 	lowerCAmelCase    (       __UpperCamelCase   ):
 '''simple docstring'''





 UpperCAmelCase__       :	Any        =       len(A__   )
 UpperCAmelCase__       :	Union[str, Any]        =       [[0 for x in range(A__   )] for x in range(A__   )]
 UpperCAmelCase__       :	List[Any]        =       [[0 for x in range(A__   )] for x in range(A__   )]

 for chain_length in range(2				,     A__   ):
  for a in range(1				,     n - chain_length + 1   ):
   UpperCAmelCase__       :	int        =       a + chain_length - 1

   UpperCAmelCase__       :	List[Any]        =       sys.maxsize
   for c in range(A__				,     A__   ):
    UpperCAmelCase__       :	List[str]        =       (
        matrix[a][c] + matrix[c + 1][b] + array[a - 1] * array[c] * array[b]
    )
    if cost < matrix[a][b]:
     UpperCAmelCase__       :	List[Any]        =       cost
     UpperCAmelCase__       :	Any        =       c
 return matrix, sol
def 	lowerCAmelCase    (       __UpperCamelCase				,     __UpperCamelCase				,     __UpperCamelCase   ):
 '''simple docstring'''





 if i == j:
  print("""A""" + str(A__   )				,     end=""" """   )
 else:
  print("""("""				,     end=""" """   )
  print_optiomal_solution(A__				,     A__				,     optimal_solution[i][j]   )
  print_optiomal_solution(A__				,     optimal_solution[i][j] + 1				,     A__   )
  print(""")"""				,     end=""" """   )
def 	lowerCAmelCase    (       ):
 '''simple docstring'''





 UpperCAmelCase__       :	Tuple        =       [30, 35, 15, 5, 10, 20, 25]
 UpperCAmelCase__       :	Optional[Any]        =       len(A__   )
 # Size of matrix created from above array will be
 # 30*35 35*15 15*5 5*10 10*20 20*25
 UpperCAmelCase__       :	Optional[int]        =       matrix_chain_order(A__   )

 print("""No. of Operation required: """ + str(matrix[1][n - 1]   )   )
 print_optiomal_solution(A__				,     1				,     n - 1   )


if __name__ == "__main__":
      main()









'''simple docstring'''






from __future__ import annotations







def 							UpperCamelCase_     (       A__   :  list				,       A__   :  int				,       A__   :  int				,       A__   :  int   ):
  '''simple docstring'''





  lowerCAmelCase_     : int     =  []
  lowerCAmelCase_,				lowerCAmelCase_     : Any     =  input_list[low:mid], input_list[mid : high + 1]
  while left and right:
    result.append((left if left[0] <= right[0] else right).pop(0   )   )
  lowerCAmelCase_     : Dict     =  result + left + right
  return input_list







def 							UpperCamelCase_     (       A__   :  list   ):
  '''simple docstring'''





  if len(A__   ) <= 1:
    return input_list
  lowerCAmelCase_     : str     =  list(A__   )

  # iteration for two-way merging
  lowerCAmelCase_     : Dict     =  2
  while p <= len(A__   ):
    # getting low, high and middle value for merge-sort of single list
    for i in range(0				,       len(A__   )				,       A__   ):
      lowerCAmelCase_     : Tuple     =  i
      lowerCAmelCase_     : List[str]     =  i + p - 1
      lowerCAmelCase_     : Optional[Any]     =  (low + high + 1) // 2
      lowerCAmelCase_     : List[str]     =  merge(A__				,       A__				,       A__				,       A__   )
    # final merge of last two parts
    if p * 2 >= len(A__   ):
      lowerCAmelCase_     : Union[str, Any]     =  i
      lowerCAmelCase_     : Dict     =  merge(A__				,       0				,       A__				,       len(A__   ) - 1   )
      break
    p *= 2

  return input_list


if __name__ == "__main__":
  __A   :    int											= input("Enter numbers separated by a comma:\n").strip()
  if user_input == "":
    __A   :    str											= []
  else:
    __A   :    Optional[Any]											= [int(item.strip()) for item in user_input.split(",")]
  print(iter_merge_sort(unsorted))



