





from __future__ import annotations

from collections import deque
from queue import Queue
from timeit import timeit

_SCREAMING_SNAKE_CASE   						=		{
    """A""": ["""B""", """C"""],
    """B""": ["""A""", """D""", """E"""],
    """C""": ["""A""", """F"""],
    """D""": ["""B"""],
    """E""": ["""B""", """F"""],
    """F""": ["""C""", """E"""],
}


def 				SCREAMING_SNAKE_CASE__    (     __a ,			__a ):
	snake_case_		:      Tuple           =						{start}
	snake_case_		:      str           =						[start]
	snake_case_		:      Queue           =						Queue()
	queue.put(__a )
	while not queue.empty():
		snake_case_		:      Tuple           =						queue.get()
		for w in graph[v]:
			if w not in explored:
				explored.add(__a )
				result.append(__a )
				queue.put(__a )
	return result


def 				SCREAMING_SNAKE_CASE__    (     __a ,			__a ):
	snake_case_		:      Any           =						{start}
	snake_case_		:      List[str]           =						[start]
	snake_case_		:      Optional[Any]           =						deque([start] )
	while queue:
		snake_case_		:      Optional[int]           =						queue.popleft()
		for child in graph[v]:
			if child not in visited:
				visited.add(__a )
				result.append(__a )
				queue.append(__a )
	return result


def 				SCREAMING_SNAKE_CASE__    (     __a ):
	snake_case_		:      List[Any]           =						f"""from __main__ import G, {name}"""
	snake_case_		:      List[str]           =						1_00_00
	snake_case_		:      Dict           =						timeit(f"""{name}(G, 'A')""" ,			setup=__a ,			number=__a )
	print(f"""{name:<35} finished {number} runs in {res:.5f} seconds""" )


if __name__ == "__main__":
						import doctest

						doctest.testmod()

						benchmark_function("""breadth_first_search""")
						benchmark_function("""breadth_first_search_with_deque""")
						# breadth_first_search                finished 10000 runs in 0.20999 seconds
						# breadth_first_search_with_deque     finished 10000 runs in 0.01421 seconds


"""simple docstring"""







def 	a__   (		UpperCAmelCase__							:      list[int]      )->						int:
						UpperCAmelCase__       						=		len(UpperCAmelCase__      )
						if n in (0, 1):
												return 0
						return sum(query * (n - i - 1) for i, query in enumerate(sorted(UpperCAmelCase__      )      )      )


if __name__ == "__main__":
						import doctest

						doctest.testmod()

