



'''simple docstring'''





import math
from itertools import permutations





def 						__lowerCamelCase       (      __magic_name__	:  int						):




							if 1 < number < 4:
														# 2 and 3 are primes
														return True
							elif number < 2 or number % 2 == 0 or number % 3 == 0:
														# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
														return False

							# All primes number are in format of 6k +/- 1
							for i in range(5     , int(math.sqrt(lowerCamelCase__						) + 1						)     , 6						):
														if number % i == 0 or number % (i + 2) == 0:
																					return False
							return True





def 						__lowerCamelCase       (      __magic_name__	:  Optional[int]     , __magic_name__	:  List[str]						):
							a__							,			a__:       Tuple											=0, len(lowerCamelCase__						) - 1
							while left <= right:
														a__:       str											=(left + right) // 2
														if prime_list[middle] == target:
																					return True
														elif prime_list[middle] < target:
																					a__:       Union[str, Any]											=middle + 1
														else:
																					a__:       Optional[int]											=middle - 1

							return False





def 						__lowerCamelCase       (      ):
							a__:       int											=[n for n in range(1_001     , 10_000     , 2						) if is_prime(lowerCamelCase__						)]
							a__:       Union[str, Any]											=[]

							for number in prime_list:
														a__:       Tuple											=[]

														for prime_member in permutations(list(str(lowerCamelCase__						)						)						):
																					a__:       str											=int("".join(lowerCamelCase__						)						)

																					if prime % 2 == 0:
																												continue

																					if search(lowerCamelCase__     , lowerCamelCase__						):
																												tmp_numbers.append(lowerCamelCase__						)

														tmp_numbers.sort()
														if len(lowerCamelCase__						) >= 3:
																					candidates.append(lowerCamelCase__						)

							a__:       Optional[int]											=[]
							for candidate in candidates:
														a__:       Any											=len(lowerCamelCase__						)
														a__:       Optional[Any]											=False

														for i in range(lowerCamelCase__						):
																					for j in range(i + 1     , lowerCamelCase__						):
																												for k in range(j + 1     , lowerCamelCase__						):
																																			if (
																																			    abs(candidate[i] - candidate[j]						)
																																			    == abs(candidate[j] - candidate[k]						)
																																			    and len({candidate[i], candidate[j], candidate[k]}						) == 3
																																			):
																																										passed.append(
																																										    sorted([candidate[i], candidate[j], candidate[k]]						)						)
																																										a__:       Optional[int]											=True

																																			if found:
																																										break
																												if found:
																																			break
																					if found:
																												break

							a__:       Tuple											=set()
							for seq in passed:
														answer.add("".join([str(lowerCamelCase__						) for i in seq]						)						)

							return max(int(lowerCamelCase__						) for x in answer						)


if __name__ == "__main__":
		print(solution())










from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


__UpperCAmelCase						  =     {
    '''configuration_splinter''': ['''SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''SplinterConfig'''],
    '''tokenization_splinter''': ['''SplinterTokenizer'''],
}

try:
		if not is_tokenizers_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__UpperCAmelCase						  =     ['''SplinterTokenizerFast''']

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		__UpperCAmelCase						  =     [
		    '''SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST''',
		    '''SplinterForQuestionAnswering''',
		    '''SplinterForPreTraining''',
		    '''SplinterLayer''',
		    '''SplinterModel''',
		    '''SplinterPreTrainedModel''',
		]


if TYPE_CHECKING:
		from .configuration_splinter import SPLINTER_PRETRAINED_CONFIG_ARCHIVE_MAP, SplinterConfig
		from .tokenization_splinter import SplinterTokenizer

		try:
				if not is_tokenizers_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .tokenization_splinter_fast import SplinterTokenizerFast

		try:
				if not is_torch_available():
						raise OptionalDependencyNotAvailable()
		except OptionalDependencyNotAvailable:
				pass
		else:
				from .modeling_splinter import (
				    SPLINTER_PRETRAINED_MODEL_ARCHIVE_LIST,
				    SplinterForPreTraining,
				    SplinterForQuestionAnswering,
				    SplinterLayer,
				    SplinterModel,
				    SplinterPreTrainedModel,
				)


else:
		import sys

		__UpperCAmelCase						  =     _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)





