



"""simple docstring"""


import importlib.metadata
import subprocess
import sys

def 					_lowerCAmelCase (  lowercase_ = False		):
						UpperCAmelCase			 =					False
						if "IPython" in sys.modules:
												UpperCAmelCase			 =					'google.colab' in str(sys.modules['IPython'].get_ipython()		)

						if in_colab:
												if upgrade:
																		UpperCAmelCase			 =					['pip', 'install', '-U', 'torch']
																		subprocess.run(lowercase_						,      check=lowercase_		)
												# get the current version of torch
												UpperCAmelCase			 =					importlib.metadata.version('torch'		)
												UpperCAmelCase			 =					torch_version[: torch_version.rindex('.'		)]
												UpperCAmelCase			 =					F"""https://storage.googleapis.com/tpu-pytorch/wheels/colab/torch_xla-{torch_version_trunc}-cp37-cp37m-linux_x86_64.whl"""
												UpperCAmelCase			 =					['pip', 'install', xla_wheel]
												subprocess.run(lowercase_						,      check=lowercase_		)
						else:
												raise RuntimeError('`install_xla` utility works only on google colab.'		)











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


if __name__ == "__main__":
     import doctest

     doctest.testmod()



