


# Algorithm for the pigeonhole sorting









def 							lowerCAmelCase_	(   __lowerCamelCase      ):
							__snake_case						:     Optional[Any]									=  min(__lowerCamelCase      )  # min() finds the minimum value
							__snake_case						:     Any									=  max(__lowerCamelCase      )  # max() finds the maximum value

							__snake_case						:     List[Any]									=  max_val - min_val + 1  # size is difference of max and min values plus one

							# list of pigeonholes of size equal to the variable size
							__snake_case						:     Optional[Any]									=  [0] * size

							# Populate the pigeonholes.
							for x in a:
														assert isinstance(__lowerCamelCase				,      __lowerCamelCase      ), "integers only please"
														holes[x - min_val] += 1

							# Putting the elements back into the array in an order.
							__snake_case						:     List[Any]									=  0
							for count in range(__lowerCamelCase      ):
														while holes[count] > 0:
																					holes[count] -= 1
																					__snake_case						:     Optional[Any]									=  count + min_val
																					i += 1







def 							lowerCAmelCase_	(   ):
							__snake_case						:     int									=  [8, 3, 2, 7, 4, 6, 8]
							pigeonhole_sort(__lowerCamelCase      )
							print("Sorted order is:"				,      " ".join(__lowerCamelCase      )      )


if __name__ == "__main__":
			main()








def 					SCREAMING_SNAKE_CASE__				(							UpperCamelCase__:				List[str]     ):
		SCREAMING_SNAKE_CASE__								=   len(UpperCamelCase__     )
		SCREAMING_SNAKE_CASE__								=   sum(UpperCamelCase__     )

		SCREAMING_SNAKE_CASE__								=   [[False for x in range(s + 1     )] for y in range(n + 1     )]

		for i in range(1       , n + 1     ):
				SCREAMING_SNAKE_CASE__								=   True

		for i in range(1       , s + 1     ):
				SCREAMING_SNAKE_CASE__								=   False

		for i in range(1       , n + 1     ):
				for j in range(1       , s + 1     ):
						SCREAMING_SNAKE_CASE__								=   dp[i][j - 1]

						if arr[i - 1] <= j:
								SCREAMING_SNAKE_CASE__								=   dp[i][j] or dp[i - 1][j - arr[i - 1]]

		for j in range(int(s / 2     )       , -1       , -1     ):
				if dp[n][j] is True:
						SCREAMING_SNAKE_CASE__								=   s - 2 * j
						break

		return diff