




import math
from itertools import permutations



def    UpperCAmelCase							(  _snake_case				):

							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    UpperCAmelCase							(  _snake_case    ,			_snake_case				):
							lowerCAmelCase ,  lowerCAmelCase =		0, len(_snake_case				) - 1
							while left <= right:
														lowerCAmelCase =		(left + right) // 2
														if prime_list[middle] == target:
																					return True
														elif prime_list[middle] < target:
																					lowerCAmelCase =		middle + 1
														else:
																					lowerCAmelCase =		middle - 1

							return False



def    UpperCAmelCase							(  ):
							lowerCAmelCase =		[n for n in range(1001    ,			10000    ,			2				) if is_prime(_snake_case				)]
							lowerCAmelCase =		[]

							for number in prime_list:
														lowerCAmelCase =		[]

														for prime_member in permutations(list(str(_snake_case				)				)				):
																					lowerCAmelCase =		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				)

							lowerCAmelCase =		[]
							for candidate in candidates:
														lowerCAmelCase =		len(_snake_case				)
														lowerCAmelCase =		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]]				)				)
																																										lowerCAmelCase =		True

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

							lowerCAmelCase =		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())









from itertools import permutations



def    UpperCAmelCase							(  _snake_case = 5				):
							if gon_side < 3 or gon_side > 5:
														raise ValueError('''gon_side must be in the range [3, 5]'''				)

							# Since it's 16, we know 10 is on the outer ring
							# Put the big numbers at the end so that they are never the first number
							lowerCAmelCase =		list(range(gon_side + 1    ,			0    ,			-1				)				)
							lowerCAmelCase =		list(range(gon_side + 2    ,			gon_side * 2 + 1				)				)

							for perm in permutations(small_numbers + big_numbers				):
														lowerCAmelCase =		generate_gon_ring(_snake_case    ,			list(_snake_case				)				)
														if is_magic_gon(_snake_case				):
																					return int(''''''.join(str(_snake_case				) for n in numbers				)				)

							lowerCAmelCase =		F"""Magic {gon_side}-gon ring is impossible"""
							raise ValueError(_snake_case				)



def    UpperCAmelCase							(  _snake_case    ,			_snake_case				):
							lowerCAmelCase =		[0] * (gon_side * 3)
							lowerCAmelCase =		perm[0:3]
							perm.append(perm[1]				)

							lowerCAmelCase =		1 if gon_side < 5 else 2

							for i in range(1    ,			len(_snake_case				) // 3 + magic_number				):
														lowerCAmelCase =		perm[2 * i + 1]
														lowerCAmelCase =		result[3 * i - 1]
														lowerCAmelCase =		perm[2 * i + 2]

							return result



def    UpperCAmelCase							(  _snake_case				):
							if len(_snake_case				) % 3 != 0:
														raise ValueError('''a gon ring should have a length that is a multiple of 3'''				)

							if min(numbers[::3]				) != numbers[0]:
														return False

							lowerCAmelCase =		sum(numbers[:3]				)

							return all(sum(numbers[i : i + 3]				) == total for i in range(3    ,			len(_snake_case				)    ,			3				)				)


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



