code: 
  
  
  
  import math
  from itertools import permutations
  
  
  
  
  
  
  def 			__lowercase     (				a__     )       ->				bool:
  
  							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(a__     ) + 1     )							,     6     ):
  														if number % i == 0 or number % (i + 2) == 0:
  																					return False
  							return True
  
  
  
  
  
  
  def 			__lowercase     (				a__							,     a__     )       ->				bool:
  							__SCREAMING_SNAKE_CASE							, __SCREAMING_SNAKE_CASE								=      0, len(a__     ) - 1
  							while left <= right:
  														__SCREAMING_SNAKE_CASE								=      (left + right) // 2
  														if prime_list[middle] == target:
  																					return True
  														elif prime_list[middle] < target:
  																					__SCREAMING_SNAKE_CASE								=      middle + 1
  														else:
  																					__SCREAMING_SNAKE_CASE								=      middle - 1
  
  							return False
  
  
  
  
  
  
  def 			__lowercase     (				)       ->				Any:
  							__SCREAMING_SNAKE_CASE								=      [n for n in range(10_01							,     1_00_00							,     2     ) if is_prime(a__     )]
  							__SCREAMING_SNAKE_CASE								=      []
  
  							for number in prime_list:
  														__SCREAMING_SNAKE_CASE								=      []
  
  														for prime_member in permutations(list(str(a__     )     )     ):
  																					__SCREAMING_SNAKE_CASE								=      int(''.join(a__     )     )
  
  																					if prime % 2 == 0:
  																												continue
  
  																					if search(a__							,     a__     ):
  																												tmp_numbers.append(a__     )
  
  														tmp_numbers.sort()
  														if len(a__     ) >= 3:
  																					candidates.append(a__     )
  
  							__SCREAMING_SNAKE_CASE								=      []
  							for candidate in candidates:
  														__SCREAMING_SNAKE_CASE								=      len(a__     )
  														__SCREAMING_SNAKE_CASE								=      False
  
  														for i in range(a__     ):
  																					for j in range(i + 1							,     a__     ):
  																												for k in range(j + 1							,     a__     ):
  																																			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]]     )     )
  																																										__SCREAMING_SNAKE_CASE								=      True
  
  																																			if found:
  																																										break
  																												if found:
  																																			break
  																					if found:
  																												break
  
  							__SCREAMING_SNAKE_CASE								=      set()
  							for seq in passed:
  														answer.add(''.join([str(a__     ) for i in seq]     )     )
  
  							return max(int(a__     ) for x in answer     )
  
  
  if __name__ == "__main__":
  			print(solution())
  
  
  
  
  
  
  
style_context: 
  
  
  
  from __future__ import annotations
  
  from collections.abc import Iterable
  from dataclasses import dataclass
  from typing import Any
  
  class      UpperCAmelCase_						:
  
  						'''simple docstring'''
  
  
  
  
  						UpperCamelCase__    :				List[str]       						=						('''_front''', '''_back''', '''_len''')
  
  						@dataclass
  						class      UpperCAmelCase_						:
  
  												'''simple docstring'''
  
  
  
  
  												UpperCamelCase__    :				Any       						=						None
  												UpperCamelCase__    :				Deque._Node | None       						=						None
  												UpperCamelCase__    :				Deque._Node | None       						=						None
  
  
  
  
  
  
  
  						class      UpperCAmelCase_						:
  
  												'''simple docstring'''
  
  
  
  
  												UpperCamelCase__    :				Optional[int]       						=						('''_cur''',)
  
  
  
  
  
  
  												def __init__(					self   ,							_A	):
  
  
  
  
  
  
  
  																			'''simple docstring'''
  
  																			__SCREAMING_SNAKE_CASE								=      cur
  
  
  
  
  
  
  												def __iter__(					self	):
  
  
  
  
  
  
  
  																			'''simple docstring'''
  
  																			return self
  
  
  
  
  
  
  												def  _A			(					self	):
  
  
  
  
  
  
  
  																			'''simple docstring'''
  
  																			if self._cur is None:
  																										# finished iterating
  																										raise StopIteration
  																			__SCREAMING_SNAKE_CASE								=      self._cur.val
  																			__SCREAMING_SNAKE_CASE								=      self._cur.next_node
  
  																			return val
  
  
  
  
  
  
  
  						def __init__(					self   ,							_A = None	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      None
  													__SCREAMING_SNAKE_CASE								=      None
  													__SCREAMING_SNAKE_CASE								=      0
  
  													if iterable is not None:
  																				# append every value to the deque
  																				for val in iterable:
  																											self.append(_A	)
  
  
  
  
  
  
  						def  _A			(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      self._Node(_A   ,							_A   ,							_A	)
  													if self.is_empty():
  																				# front = back
  																				__SCREAMING_SNAKE_CASE								=      __SCREAMING_SNAKE_CASE								=      node
  																				__SCREAMING_SNAKE_CASE								=      1
  													else:
  																				# connect nodes
  																				__SCREAMING_SNAKE_CASE								=      node
  																				__SCREAMING_SNAKE_CASE								=      self._back
  																				__SCREAMING_SNAKE_CASE								=      node  # assign new back to the new node
  
  																				self._len += 1
  
  																				# make sure there were no errors
  																				assert not self.is_empty(), "Error on appending value."
  
  
  
  
  
  
  						def  _A			(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      self._Node(_A   ,							_A   ,							_A	)
  													if self.is_empty():
  																				# front = back
  																				__SCREAMING_SNAKE_CASE								=      __SCREAMING_SNAKE_CASE								=      node
  																				__SCREAMING_SNAKE_CASE								=      1
  													else:
  																				# connect nodes
  																				__SCREAMING_SNAKE_CASE								=      self._front
  																				__SCREAMING_SNAKE_CASE								=      node
  																				__SCREAMING_SNAKE_CASE								=      node  # assign new front to the new node
  
  																				self._len += 1
  
  																				# make sure there were no errors
  																				assert not self.is_empty(), "Error on appending value."
  
  
  
  
  
  
  						def  _A			(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													for val in iterable:
  																				self.append(_A	)
  
  
  
  
  
  
  						def  _A			(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													for val in iterable:
  																				self.appendleft(_A	)
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													assert not self.is_empty(), "Deque is empty."
  
  													__SCREAMING_SNAKE_CASE								=      self._back
  													__SCREAMING_SNAKE_CASE								=      self._back.prev_node  # set new back
  													# drop the last node - python will deallocate memory automatically
  													__SCREAMING_SNAKE_CASE								=      None
  
  													self._len -= 1
  
  													return topop.val
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													assert not self.is_empty(), "Deque is empty."
  
  													__SCREAMING_SNAKE_CASE								=      self._front
  													__SCREAMING_SNAKE_CASE								=      self._front.next_node  # set new front and drop the first node
  													__SCREAMING_SNAKE_CASE								=      None
  
  													self._len -= 1
  
  													return topop.val
  
  
  
  
  
  
  						def  _A			(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													return self._front is None
  
  
  
  
  
  
  						def __len__(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													return self._len
  
  
  
  
  
  
  						def __eq__(					self   ,							_A	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													if not isinstance(_A   ,							_A	):
  																				return NotImplemented
  
  													__SCREAMING_SNAKE_CASE								=      self._front
  													__SCREAMING_SNAKE_CASE								=      other._front
  
  													# if the length of the dequeues are not the same, they are not equal
  													if len(self	) != len(_A	):
  																				return False
  
  													while me is not None and oth is not None:
  																				# compare every value
  																				if me.val != oth.val:
  																											return False
  																				__SCREAMING_SNAKE_CASE								=      me.next_node
  																				__SCREAMING_SNAKE_CASE								=      oth.next_node
  
  													return True
  
  
  
  
  
  
  						def __iter__(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													return Deque._Iterator(self._front	)
  
  
  
  
  
  
  						def __repr__(					self	):
  
  
  
  
  
  
  
  													'''simple docstring'''
  
  													__SCREAMING_SNAKE_CASE								=      []
  													__SCREAMING_SNAKE_CASE								=      self._front
  													while aux is not None:
  																				# append the values in a list to display
  																				values_list.append(aux.val	)
  																				__SCREAMING_SNAKE_CASE								=      aux.next_node
  
  													return f"""[{", ".join(repr(_A	) for val in values_list	)}]"""
  
  
  if __name__ == "__main__":
  			import doctest
  
  			doctest.testmod()
  
  
  
  
  
  
  