'''simple docstring'''






import math
from itertools import permutations





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





def    _SCREAMING_SNAKE_CASE		(			__snake_case       : int      ,		__snake_case       : list							):
     _A		,					_A								=     0, len(__snake_case							) - 1
     while left <= right:
          _A								=     (left + right) // 2
          if prime_list[middle] == target:
               return True
          elif prime_list[middle] < target:
               _A								=     middle + 1
          else:
               _A								=     middle - 1

     return False





def    _SCREAMING_SNAKE_CASE		(			):
     _A								=     [n for n in range(1_0_0_1      ,		1_0_0_0_0      ,		2							) if is_prime(__snake_case							)]
     _A								=     []

     for number in prime_list:
          _A								=     []

          for prime_member in permutations(list(str(__snake_case							)							)							):
               _A								=     int(''.join(__snake_case							)							)

               if prime % 2 == 0:
                    continue

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

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

     _A								=     []
     for candidate in candidates:
          _A								=     len(__snake_case							)
          _A								=     False

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

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

     _A								=     set()
     for seq in passed:
          answer.add(''.join([str(__snake_case							) for i in seq]							)							)

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


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




'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_UpperCAmelCase						:    Dict     					=					{
    '''configuration_decision_transformer''': [
        '''DECISION_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''DecisionTransformerConfig''',
    ],
}

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _UpperCAmelCase						:    Union[str, Any]     					=					[
       '''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

   _UpperCAmelCase						:    Dict     					=					_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)



