"""simple docstring"""







from typing import Any


class       _lowercase		:

				def __init__(  self							:     List[Any]  ):


										'''simple docstring'''
										UpperCAmelCase__       						=		[]
										UpperCAmelCase__       						=		0

				def __str__(  self							:     str  ):


										'''simple docstring'''
										UpperCAmelCase__       						=		"""<""" + str(self.stack  )[1:-1] + """>"""
										return printed

				def 							A			(  self							:     int							,     _lowercase							:     Any  ):


										'''simple docstring'''
										self.stack.append(_lowercase  )
										UpperCAmelCase__       						=		self.length + 1

				def 							A			(  self							:     int  ):


										'''simple docstring'''
										self.rotate(1  )
										UpperCAmelCase__       						=		self.stack[self.length - 1]
										UpperCAmelCase__       						=		self.stack[:-1]
										self.rotate(self.length - 1  )
										UpperCAmelCase__       						=		self.length - 1
										return dequeued

				def 							A			(  self							:     int							,     _lowercase							:     int  ):


										'''simple docstring'''
										for _ in range(_lowercase  ):
																UpperCAmelCase__       						=		self.stack[0]
																UpperCAmelCase__       						=		self.stack[1:]
																self.put(_lowercase  )
																UpperCAmelCase__       						=		self.length - 1

				def 							A			(  self							:     Optional[Any]  ):


										'''simple docstring'''
										UpperCAmelCase__       						=		self.get()
										self.put(_lowercase  )
										self.rotate(self.length - 1  )
										return front

				def 							A			(  self							:     Dict  ):


										'''simple docstring'''
										return self.length


"""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()

