import math
from itertools import permutations







def  __lowerCAmelCase							(						__SCREAMING_SNAKE_CASE    : int					):







    '''simple docstring'''





    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(_SCREAMING_SNAKE_CASE					) + 1					)						,				6					):
        if number % i == 0 or number % (i + 2) == 0:
            return False
    return True







def  __lowerCAmelCase							(						__SCREAMING_SNAKE_CASE    : int						,				__SCREAMING_SNAKE_CASE    : list					):







    '''simple docstring'''
    __snake_case    :							Any             =  0, len(_SCREAMING_SNAKE_CASE					) - 1
    while left <= right:
        __snake_case    :							List[str]             =  (left + right) // 2
        if prime_list[middle] == target:
            return True
        elif prime_list[middle] < target:
            __snake_case    :							Dict             =  middle + 1
        else:
            __snake_case    :							int             =  middle - 1

    return False







def  __lowerCAmelCase							(						):







    '''simple docstring'''
    __snake_case    :							Dict             =  [n for n in range(1_0_0_1						,				1_0_0_0_0						,				2					) if is_prime(_SCREAMING_SNAKE_CASE					)]
    __snake_case    :							Optional[int]             =  []

    for number in prime_list:
        __snake_case    :							Optional[Any]             =  []

        for prime_member in permutations(list(str(_SCREAMING_SNAKE_CASE					)					)					):
            __snake_case    :							List[Any]             =  int("""""".join(_SCREAMING_SNAKE_CASE					)					)

            if prime % 2 == 0:
                continue

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

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

    __snake_case    :							Tuple             =  []
    for candidate in candidates:
        __snake_case    :							Union[str, Any]             =  len(_SCREAMING_SNAKE_CASE					)
        __snake_case    :							Any             =  False

        for i in range(_SCREAMING_SNAKE_CASE					):
            for j in range(i + 1						,				_SCREAMING_SNAKE_CASE					):
                for k in range(j + 1						,				_SCREAMING_SNAKE_CASE					):
                    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]]					)					)
                        __snake_case    :							Optional[Any]             =  True

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

    __snake_case    :							Any             =  set()
    for seq in passed:
        answer.add("""""".join([str(_SCREAMING_SNAKE_CASE					) for i in seq]					)					)

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


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






'''simple docstring'''
from transformers import PretrainedConfig
class  _snake_case						(__SCREAMING_SNAKE_CASE):
			__A   :     Optional[Any]          ="custom"






			def __init__(   self       ,_snake_case=1       ,**_snake_case			):
				UpperCAmelCase_			:	Optional[int]      =   attribute
				super().__init__(**_snake_case			)




class  _snake_case						(__SCREAMING_SNAKE_CASE):
			__A   :     Dict          ="custom"






			def __init__(   self       ,_snake_case=1       ,**_snake_case			):
				UpperCAmelCase_			:	Optional[int]      =   attribute




