


import math
from itertools import permutations




def 			__lowercase	(						_UpperCamelCase     )    ->bool:







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




def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->bool:







      """simple docstring"""

      lowercase   ,			lowercase			:   Tuple					   =		0, len(__lowerCamelCase     ) - 1
      while left <= right:
            lowercase			:   Optional[int]					   =		(left + right) // 2
            if prime_list[middle] == target:
                  return True
            elif prime_list[middle] < target:
                  lowercase			:   Optional[Any]					   =		middle + 1
            else:
                  lowercase			:   Dict					   =		middle - 1

      return False




def 			__lowercase	(						)    ->List[Any]:







      """simple docstring"""

      lowercase			:   Tuple					   =		[n for n in range(1001,    10000,    2     ) if is_prime(__lowerCamelCase     )]
      lowercase			:   List[str]					   =		[]

      for number in prime_list:
            lowercase			:   List[str]					   =		[]

            for prime_member in permutations(list(str(__lowerCamelCase     )     )     ):
                  lowercase			:   List[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     )

      lowercase			:   str					   =		[]
      for candidate in candidates:
            lowercase			:   int					   =		len(__lowerCamelCase     )
            lowercase			:   Union[str, 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]]     )     )
                                    lowercase			:   Any					   =		True

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

      lowercase			:   Optional[int]					   =		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_torch_available


__a   				=      {
    '''configuration_decision_transformer''': [
        '''DECISION_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''DecisionTransformerConfig''',
    ],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __a   				=      [
      '''DECISION_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
      '''DecisionTransformerGPT2Model''',
      '''DecisionTransformerGPT2PreTrainedModel''',
      '''DecisionTransformerModel''',
      '''DecisionTransformerPreTrainedModel''',
  ]


if TYPE_CHECKING:
  from .configuration_decision_transformer import (
      DECISION_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
      DecisionTransformerConfig,
  )

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_decision_transformer import (
        DECISION_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
        DecisionTransformerGPTaModel,
        DecisionTransformerGPTaPreTrainedModel,
        DecisionTransformerModel,
        DecisionTransformerPreTrainedModel,
    )


else:
  import sys

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

