import typing


def parse_array_encoding(array_encoding: bytes) -> typing.Tuple[int, bytes]:
	"""Parse an array type encoding into its length and element type encoding."""
	
	if not array_encoding.startswith(b"["):
		raise ValueError(f"Missing opening bracket in array type encoding: {array_encoding!r}")
	if not array_encoding.endswith(b"]"):
		raise ValueError(f"Missing closing bracket in array type encoding: {array_encoding!r}")
	
	i = 1
	while i < len(array_encoding) - 1:
		if array_encoding[i] not in b"0123456789":
			break
		i += 1
	length_string, element_type_encoding = array_encoding[1:i], array_encoding[i:-1]
	
	if not length_string:
		raise ValueError(f"Missing length in array type encoding: {array_encoding!r}")
	if not element_type_encoding:
		raise ValueError(f"Missing element type in array type encoding: {array_encoding!r}")
	
	return int(length_string.decode("ascii")), element_type_encoding