


"""simple docstring"""



def     UpperCAmelCase    (					_lowercase   :      int  )	->   int:


	"""simple docstring"""




	barcode //= 1_0  # exclude the last digit
	lowerCAmelCase_			       = False
	lowerCAmelCase_			       = 0

	# extract and check each digit
	while barcode != 0:
		lowerCAmelCase_			       = 1 if checker else 3
		s += mult * (barcode % 1_0)
		barcode //= 1_0
		lowerCAmelCase_			       = not checker

	return (1_0 - (s % 1_0)) % 1_0
def     UpperCAmelCase    (					_lowercase   :      int  )	->   bool:


	"""simple docstring"""




	return len(str(_lowercase  )  ) == 1_3 and get_check_digit(_lowercase  ) == barcode % 1_0
def     UpperCAmelCase    (					_lowercase   :      str  )	->   int:


	"""simple docstring"""




	if str(_lowercase  ).isalpha():
		lowerCAmelCase_			       = F"""Barcode '{barcode}' has alphabetic characters."""
		raise ValueError(_lowercase  )
	elif int(_lowercase  ) < 0:
		raise ValueError('''The entered barcode has a negative value. Try again.'''  )
	else:
		return int(_lowercase  )


if __name__ == "__main__":
		import doctest

		doctest.testmod()
		lowercase_							 =       get_barcode(input('Barcode: ').strip())

		if is_valid(barcode):
				print(f"""'{barcode}' is a valid barcode.""")
		else:
				print(f"""'{barcode}' is NOT a valid barcode.""")



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