


from __future__ import annotations

from collections.abc import Callable
from typing import Any, Generic, TypeVar

snake_case__			 =						TypeVar('''T''')


class 					lowerCAmelCase_ (       Generic[T]):




						def __init__(	self						:   Dict   ,     __A						:   list[T]   ,     __A						:   Callable[[T, T], T]						)      ->None:






									"""simple docstring"""






									a__ :Any | T						  =    None

									a__ :int						  =    len(__A						)
									a__ :list[T]						  =    [any_type for _ in range(self.N						)] + arr
									a__ :Union[str, Any]						  =    fnc
									self.build()




						def  _snake_case					(	self						:   Any						)      ->None:






									"""simple docstring"""






									for p in range(self.N - 1   ,     0   ,     -1						):
												a__ :Optional[int]						  =    self.fn(self.st[p * 2]   ,     self.st[p * 2 + 1]						)




						def  _snake_case					(	self						:   Tuple   ,     __A						:   int   ,     __A						:   T						)      ->None:






									"""simple docstring"""






									p += self.N
									a__ :Union[str, Any]						  =    v
									while p > 1:
												a__ :Optional[int]						  =    p // 2
												a__ :str						  =    self.fn(self.st[p * 2]   ,     self.st[p * 2 + 1]						)






						def  _snake_case					(	self						:   Any   ,     __A						:   int   ,     __A						:   int						)      ->T | None:  # noqa: E741






									"""simple docstring"""






									a__  ,  a__ :Union[str, Any]						  =    l + self.N, r + self.N

									a__ :T | None						  =    None
									while l <= r:
												if l % 2 == 1:
															a__ :Optional[Any]						  =    self.st[l] if res is None else self.fn(__A   ,     self.st[l]						)
												if r % 2 == 0:
															a__ :Dict						  =    self.st[r] if res is None else self.fn(__A   ,     self.st[r]						)
												a__  ,  a__ :Union[str, Any]						  =    (l + 1) // 2, (r - 1) // 2
									return res


if __name__ == "__main__":
		from functools import reduce

		snake_case__			 =						[1, 10, -2, 9, -3, 8, 4, -7, 5, 6, 11, -12]

		snake_case__			 =						{
		    0: 7,
		    1: 2,
		    2: 6,
		    3: -14,
		    4: 5,
		    5: 4,
		    6: 7,
		    7: -10,
		    8: 9,
		    9: 10,
		    10: 12,
		    11: 1,
		}

		snake_case__			 =						SegmentTree(test_array, min)
		snake_case__			 =						SegmentTree(test_array, max)
		snake_case__			 =						SegmentTree(test_array, lambda a, b: a + b)


		def 				lowerCamelCase__	(      )    ->	None:





					"""simple docstring"""
					for i in range(len(a				)				):
								for j in range(a	,  len(a				)				):
											a__ :Dict						  =    reduce(a	,  test_array[i : j + 1]				)
											a__ :int						  =    reduce(a	,  test_array[i : j + 1]				)
											a__ :Optional[Any]						  =    reduce(lambda a	,  a				: a + b	,  test_array[i : j + 1]				)
											assert min_range == min_segment_tree.query(a	,  a				)
											assert max_range == max_segment_tree.query(a	,  a				)
											assert sum_range == sum_segment_tree.query(a	,  a				)

		test_all_segments()

		for index, value in test_updates.items():
				snake_case__			 =						value
				min_segment_tree.update(index, value)
				max_segment_tree.update(index, value)
				sum_segment_tree.update(index, value)
				test_all_segments()






def 				lowerCamelCase__	(      a	:   int = 100				)    ->	int:





			"""simple docstring"""
			a__ :Tuple						  =    n * (n + 1) * (2 * n + 1) / 6
			a__ :Tuple						  =    (n * (n + 1) / 2) ** 2
			return int(square_of_sum - sum_of_squares				)


if __name__ == "__main__":
		print(f'''{solution() = }''')


