



'''simple docstring'''

from __future__ import annotations

import sys



def   __lowerCamelCase  (   lowerCAmelCase_		,    lowerCAmelCase_						)    ->   tuple[int, int]:
		# base cases
		if abs(lowerCAmelCase_						) == 1:
				return a, 0
		elif abs(lowerCAmelCase_						) == 1:
				return 0, b

		_a  :   str				 =							a, b
		_a  :   str				 =							1, 0
		_a  :   Dict				 =							0, 1

		while remainder != 0:
				_a  :   Optional[Any]				 =							old_remainder // remainder
				_a  :   Tuple				 =							remainder, old_remainder - quotient * remainder
				_a  :   int				 =							coeff_a, old_coeff_a - quotient * coeff_a
				_a  :   List[Any]				 =							coeff_b, old_coeff_b - quotient * coeff_b

		# sign correction for negative numbers
		if a < 0:
				_a  :   Optional[Any]				 =							-old_coeff_a
		if b < 0:
				_a  :   List[str]				 =							-old_coeff_b

		return old_coeff_a, old_coeff_b



def   __lowerCamelCase  (   )    ->   int:
		if len(sys.argv						) < 3:
				print('2 integer arguments required'						)
				return 1
		_a  :   Optional[int]				 =							int(sys.argv[1]						)
		_a  :   List[str]				 =							int(sys.argv[2]						)
		print(extended_euclidean_algorithm(lowerCAmelCase_		,    lowerCAmelCase_						)						)
		return 0


if __name__ == "__main__":
							raise SystemExit(main())









'''simple docstring'''

def   __lowerCamelCase  (   lowerCAmelCase_						)    ->   tuple[int, int]:
		# base case
		if len(lowerCAmelCase_						) == 1:
				return a[0], a[0]
		else:
				# split A into half.
				_a  :   Union[str, Any]				 =							a[: len(lowerCAmelCase_						) // 2]
				_a  :   List[Any]				 =							a[len(lowerCAmelCase_						) // 2 :]

				# 2 sub problems, 1/2 of original size.
				_a ,      _a  :   Any				 =							max_difference(lowerCAmelCase_						)
				_a ,      _a  :   Any				 =							max_difference(lowerCAmelCase_						)

				# get min of first and max of second
				# linear time
				_a  :   Union[str, Any]				 =							min(lowerCAmelCase_						)
				_a  :   Optional[int]				 =							max(lowerCAmelCase_						)

				# 3 cases, either (small1, big1),
				# (min_first, max_second), (small2, big2)
				# constant comparisons
				if biga - smalla > max_second - min_first and biga - smalla > biga - smalla:
						return smalla, biga
				elif biga - smalla > max_second - min_first:
						return smalla, biga
				else:
						return min_first, max_second


if __name__ == "__main__":
							import doctest

							doctest.testmod()




