





from __future__ import annotations

import math


class 						lowercase    :




							def __init__(						self   :					Optional[int]	,							_UpperCamelCase   :					int      )					->				List[str]:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       size
												# approximate the overall size of segment tree with given value
												SCREAMING_SNAKE_CASE    			=       [0 for i in range(0	,							4 * size      )]
												# create array to store lazy update
												SCREAMING_SNAKE_CASE    			=       [0 for i in range(0	,							4 * size      )]
												SCREAMING_SNAKE_CASE    			=       [0 for i in range(0	,							4 * size      )]  # flag for lazy update




							def 	__snake_case(						self   :					Union[str, Any]	,							_UpperCamelCase   :					int      )					->				Any:



												'''simple docstring'''

												return idx * 2




							def 	__snake_case(						self   :					Tuple	,							_UpperCamelCase   :					int      )					->				str:



												'''simple docstring'''

												return idx * 2 + 1




							def 	__snake_case(						self   :					Optional[int]	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					list[int]      )					->				Optional[Any]:



												'''simple docstring'''

												if left_element == right_element:
																	SCREAMING_SNAKE_CASE    			=       a[left_element - 1]
												else:
																	SCREAMING_SNAKE_CASE    			=       (left_element + right_element) // 2
																	self.build(self.left(_lowercase      )	,							_lowercase	,							_lowercase	,							_lowercase      )
																	self.build(self.right(_lowercase      )	,							mid + 1	,							_lowercase	,							_lowercase      )
																	SCREAMING_SNAKE_CASE    			=       max(
																	    self.segment_tree[self.left(_lowercase      )]	,							self.segment_tree[self.right(_lowercase      )]      )




							def 	__snake_case(						self   :					List[Any]	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					int      )					->				Tuple:



												'''simple docstring'''

												if self.flag[idx] is True:
																	SCREAMING_SNAKE_CASE    			=       self.lazy[idx]
																	SCREAMING_SNAKE_CASE    			=       False
																	if left_element != right_element:
																						SCREAMING_SNAKE_CASE    			=       self.lazy[idx]
																						SCREAMING_SNAKE_CASE    			=       self.lazy[idx]
																						SCREAMING_SNAKE_CASE    			=       True
																						SCREAMING_SNAKE_CASE    			=       True

												if right_element < a or left_element > b:
																	return True
												if left_element >= a and right_element <= b:
																	SCREAMING_SNAKE_CASE    			=       val
																	if left_element != right_element:
																						SCREAMING_SNAKE_CASE    			=       val
																						SCREAMING_SNAKE_CASE    			=       val
																						SCREAMING_SNAKE_CASE    			=       True
																						SCREAMING_SNAKE_CASE    			=       True
																	return True
												SCREAMING_SNAKE_CASE    			=       (left_element + right_element) // 2
												self.update(self.left(_lowercase      )	,							_lowercase	,							_lowercase	,							_lowercase	,							_lowercase	,							_lowercase      )
												self.update(self.right(_lowercase      )	,							mid + 1	,							_lowercase	,							_lowercase	,							_lowercase	,							_lowercase      )
												SCREAMING_SNAKE_CASE    			=       max(
												    self.segment_tree[self.left(_lowercase      )]	,							self.segment_tree[self.right(_lowercase      )]      )
												return True




							def 	__snake_case(						self   :					List[Any]	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					int	,							_UpperCamelCase   :					int      )					->				Optional[Any]:



												'''simple docstring'''

												if self.flag[idx] is True:
																	SCREAMING_SNAKE_CASE    			=       self.lazy[idx]
																	SCREAMING_SNAKE_CASE    			=       False
																	if left_element != right_element:
																						SCREAMING_SNAKE_CASE    			=       self.lazy[idx]
																						SCREAMING_SNAKE_CASE    			=       self.lazy[idx]
																						SCREAMING_SNAKE_CASE    			=       True
																						SCREAMING_SNAKE_CASE    			=       True
												if right_element < a or left_element > b:
																	return -math.inf
												if left_element >= a and right_element <= b:
																	return self.segment_tree[idx]
												SCREAMING_SNAKE_CASE    			=       (left_element + right_element) // 2
												SCREAMING_SNAKE_CASE    			=       self.query(self.left(_lowercase      )	,							_lowercase	,							_lowercase	,							_lowercase	,							_lowercase      )
												SCREAMING_SNAKE_CASE    			=       self.query(self.right(_lowercase      )	,							mid + 1	,							_lowercase	,							_lowercase	,							_lowercase      )
												return max(_lowercase	,							_lowercase      )





							def __str__(						self   :					Tuple      )					->				Union[str, Any]:



												'''simple docstring'''

												return str([self.query(1	,							1	,							self.size	,							_lowercase	,							_lowercase      ) for i in range(1	,							self.size + 1      )]      )


if __name__ == "__main__":
							_lowerCamelCase					:   List[Any]							=		[1, 2, -4, 7, 3, -5, 6, 11, -20, 9, 14, 15, 5, 2, -8]
							_lowerCamelCase					:   str							=		15
							_lowerCamelCase					:   int							=		SegmentTree(size)
							segt.build(1, 1, size, A)
							print(segt.query(1, 1, size, 4, 6))
							print(segt.query(1, 1, size, 7, 11))
							print(segt.query(1, 1, size, 7, 12))
							segt.update(1, 1, size, 1, 3, 1_11)
							print(segt.query(1, 1, size, 1, 15))
							segt.update(1, 1, size, 7, 8, 2_35)
							print(segt)





def 	__lowerCamelCase							(UpperCAmelCase__     :							int  ):
					assert isinstance(UpperCAmelCase__      , UpperCAmelCase__  ), F"The input value of [n={number}] is not an integer"

					if number == 1:
										return 2
					elif number < 1:
										SCREAMING_SNAKE_CASE    			=       F"The input value of [n={number}] has to be > 0"
										raise ValueError(UpperCAmelCase__  )
					else:
										SCREAMING_SNAKE_CASE    			=       sylvester(number - 1  )
										SCREAMING_SNAKE_CASE    			=       num - 1
										SCREAMING_SNAKE_CASE    			=       num
										return lower * upper + 1


if __name__ == "__main__":
							print(f"""The 8th number in Sylvester's sequence: {sylvester(8)}""")




