

lowerCAmelCase							:  Optional[Any]   	=						range(2, 20 + 1)
lowerCAmelCase							:  Dict   	=						[10**k for k in range(ks[-1] + 1)]
lowerCAmelCase							:  dict[int, dict[int, list[list[int]]]]   	=						{}







def 			A_      (    _UpperCAmelCase				,	_UpperCAmelCase				,	_UpperCAmelCase				,	_UpperCAmelCase    ):
						SCREAMING_SNAKE_CASE_: Optional[Any]  		=       sum(a_i[j] for j in range(_UpperCAmelCase				,	len(_UpperCAmelCase    )    )    )
						SCREAMING_SNAKE_CASE_: Optional[int]  		=       sum(a_i[j] * base[j] for j in range(min(len(_UpperCAmelCase    )				,	_UpperCAmelCase    )    )    )

						SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: str  		=       0, 0
						SCREAMING_SNAKE_CASE_: int  		=       n - i

						SCREAMING_SNAKE_CASE_: str  		=       memo.get(_UpperCAmelCase    )

						if sub_memo is not None:
												SCREAMING_SNAKE_CASE_: int  		=       sub_memo.get(_UpperCAmelCase    )

												if jumps is not None and len(_UpperCAmelCase    ) > 0:
																		# find and make the largest jump without going over
																		SCREAMING_SNAKE_CASE_: str  		=       -1
																		for _k in range(len(_UpperCAmelCase    ) - 1				,	-1				,	-1    ):
																								if jumps[_k][2] <= k and jumps[_k][1] <= max_dn:
																														SCREAMING_SNAKE_CASE_: Optional[Any]  		=       _k
																														break

																		if max_jump >= 0:
																								SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       jumps[max_jump]
																								# since the difference between jumps is cached, add c
																								SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       diff + c
																								for j in range(min(_UpperCAmelCase				,	len(_UpperCAmelCase    )    )    ):
																														SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: List[Any]  		=       divmod(_UpperCAmelCase				,	10    )
																								if new_c > 0:
																														add(_UpperCAmelCase				,	_UpperCAmelCase				,	_UpperCAmelCase    )

												else:
																		SCREAMING_SNAKE_CASE_: List[Any]  		=       []
						else:
												SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       {c: []}
												SCREAMING_SNAKE_CASE_: List[str]  		=       sub_memo

						if dn >= max_dn or c + diff >= base[k]:
												return diff, dn

						if k > ks[0]:
												while True:
																		# keep doing smaller jumps
																		SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       next_term(_UpperCAmelCase				,	k - 1				,	i + dn				,	_UpperCAmelCase    )
																		diff += _diff
																		dn += terms_jumped

																		if dn >= max_dn or c + diff >= base[k]:
																								break
						else:
												# would be too small a jump, just compute sequential terms instead
												SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       compute(_UpperCAmelCase				,	_UpperCAmelCase				,	i + dn				,	_UpperCAmelCase    )
												diff += _diff
												dn += terms_jumped

						SCREAMING_SNAKE_CASE_: Dict  		=       sub_memo[c]

						# keep jumps sorted by # of terms skipped
						SCREAMING_SNAKE_CASE_: Tuple  		=       0
						while j < len(_UpperCAmelCase    ):
												if jumps[j][1] > dn:
																		break
												j += 1

						# cache the jump for this value digitsum(b) and c
						sub_memo[c].insert(_UpperCAmelCase				,	(diff, dn, k)    )
						return (diff, dn)







def 			A_      (    _UpperCAmelCase				,	_UpperCAmelCase				,	_UpperCAmelCase				,	_UpperCAmelCase    ):
						if i >= n:
												return 0, i
						if k > len(_UpperCAmelCase    ):
												a_i.extend([0 for _ in range(k - len(_UpperCAmelCase    )    )]    )

						# note: a_i -> b * 10^k + c
						# ds_b -> digitsum(b)
						# ds_c -> digitsum(c)
						SCREAMING_SNAKE_CASE_: Tuple  		=       i
						SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: Any  		=       0, 0, 0
						for j in range(len(_UpperCAmelCase    )    ):
												if j >= k:
																		ds_b += a_i[j]
												else:
																		ds_c += a_i[j]

						while i < n:
												i += 1
												SCREAMING_SNAKE_CASE_: Optional[int]  		=       ds_c + ds_b
												diff += addend
												SCREAMING_SNAKE_CASE_: Dict  		=       0
												for j in range(_UpperCAmelCase    ):
																		SCREAMING_SNAKE_CASE_: Optional[int]  		=       a_i[j] + addend
																		SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: int  		=       divmod(_UpperCAmelCase				,	10    )

																		ds_c += a_i[j]

												if addend > 0:
																		break

						if addend > 0:
												add(_UpperCAmelCase				,	_UpperCAmelCase				,	_UpperCAmelCase    )
						return diff, i - start_i







def 			A_      (    _UpperCAmelCase				,	_UpperCAmelCase				,	_UpperCAmelCase    ):
						for j in range(_UpperCAmelCase				,	len(_UpperCAmelCase    )    ):
												SCREAMING_SNAKE_CASE_: str  		=       digits[j] + addend
												if s >= 10:
																		SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: int  		=       divmod(_UpperCAmelCase				,	10    )
																		SCREAMING_SNAKE_CASE_: List[str]  		=       addend // 10 + quotient
												else:
																		SCREAMING_SNAKE_CASE_: Tuple  		=       s
																		SCREAMING_SNAKE_CASE_: List[Any]  		=       addend // 10

												if addend == 0:
																		break

						while addend > 0:
												SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: Tuple  		=       divmod(_UpperCAmelCase				,	10    )
												digits.append(_UpperCAmelCase    )







def 			A_      (    _UpperCAmelCase = 10**15    ):
						SCREAMING_SNAKE_CASE_: str  		=       [1]
						SCREAMING_SNAKE_CASE_: List[str]  		=       1
						SCREAMING_SNAKE_CASE_: Dict  		=       0
						while True:
												SCREAMING_SNAKE_CASE_		,    SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       next_term(_UpperCAmelCase				,	20				,	i + dn				,	_UpperCAmelCase    )
												dn += terms_jumped
												if dn == n - i:
																		break

						SCREAMING_SNAKE_CASE_: Union[str, Any]  		=       0
						for j in range(len(_UpperCAmelCase    )    ):
												a_n += digits[j] * 10**j
						return a_n


if __name__ == "__main__":
						print(f'''{solution() = }''')







def       _snake_case	(   lowerCAmelCase							:   list	):
		"""simple docstring"""







		SCREAMING_SNAKE_CASE_  :		Dict				      =    len(lowerCAmelCase	)
		for i in range(1   , lowerCAmelCase	):
				SCREAMING_SNAKE_CASE_  :		int				      =    collection[i]
				SCREAMING_SNAKE_CASE_  :		Any				      =    0
				SCREAMING_SNAKE_CASE_  :		Tuple				      =    i - 1

				while low <= high:
						SCREAMING_SNAKE_CASE_  :		int				      =    (low + high) // 2
						if val < collection[mid]:
								SCREAMING_SNAKE_CASE_  :		Optional[Any]				      =    mid - 1
						else:
								SCREAMING_SNAKE_CASE_  :		Tuple				      =    mid + 1
				for j in range(lowerCAmelCase   , lowerCAmelCase   , -1	):
						SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    collection[j - 1]
				SCREAMING_SNAKE_CASE_  :		int				      =    val
		return collection


if __name__ == "__main__":
		__lowerCamelCase					:	Dict       =  input('''Enter numbers separated by a comma:\n''').strip()
		__lowerCamelCase					:	List[str]       =  [int(item) for item in user_input.split(''',''')]
		print(binary_insertion_sort(unsorted))
