





"""simple docstring"""




from collections.abc import Callable


class        __UpperCamelCase				:






							def __init__(   self      ,					lowerCAmelCase__ = None      )	-> None:
								# Stores actual heap items.
								a      :		list	=				[]
								# Stores indexes of each item for supporting updates and deletion.
								a      :		dict	=				{}
								# Stores current size of heap.
								a      :		Dict	=				0
								# Stores function used to evaluate the score of an item on which basis ordering
								# will be done.
								a      :		List[str]	=				key or (lambda lowerCAmelCase__      : x)






							def     __a   (   self      ,					lowerCAmelCase__      )	-> int | None:
								return int((i - 1) / 2      ) if i > 0 else None






							def     __a   (   self      ,					lowerCAmelCase__      )	-> int | None:
								a      :		Dict	=				int(2 * i + 1      )
								return left if 0 < left < self.size else None






							def     __a   (   self      ,					lowerCAmelCase__      )	-> int | None:
								a      :		str	=				int(2 * i + 2      )
								return right if 0 < right < self.size else None






							def     __a   (   self      ,					lowerCAmelCase__      ,					lowerCAmelCase__      )	-> None:
								a,       a      :		Optional[Any]	=				(
								    self.pos_map[self.arr[j][0]],
								    self.pos_map[self.arr[i][0]],
								)
								# Then swap the items in the list.
								a,       a      :		Optional[Any]	=				self.arr[j], self.arr[i]






							def     __a   (   self      ,					lowerCAmelCase__      ,					lowerCAmelCase__      )	-> bool:
								return self.arr[i][1] < self.arr[j][1]






							def     __a   (   self      ,					lowerCAmelCase__      )	-> int:
								a      :		Optional[Any]	=				self._left(lowerCAmelCase__      )
								a      :		int	=				self._right(lowerCAmelCase__      )
								a      :		List[Any]	=				i

								if left is not None and not self._cmp(lowerCAmelCase__      ,					lowerCAmelCase__      ):
									a      :		Optional[Any]	=				left
								if right is not None and not self._cmp(lowerCAmelCase__      ,					lowerCAmelCase__      ):
									a      :		Any	=				right

								return valid_parent






							def     __a   (   self      ,					lowerCAmelCase__      )	-> None:
								a      :		Dict	=				self._parent(lowerCAmelCase__      )
								while parent is not None and not self._cmp(lowerCAmelCase__      ,					lowerCAmelCase__      ):
									self._swap(lowerCAmelCase__      ,					lowerCAmelCase__      )
									a,       a      :		Tuple	=				parent, self._parent(lowerCAmelCase__      )






							def     __a   (   self      ,					lowerCAmelCase__      )	-> None:
								a      :		List[Any]	=				self._get_valid_parent(lowerCAmelCase__      )
								while valid_parent != index:
									self._swap(lowerCAmelCase__      ,					lowerCAmelCase__      )
									a,       a      :		List[Any]	=				valid_parent, self._get_valid_parent(lowerCAmelCase__      )






							def     __a   (   self      ,					lowerCAmelCase__      ,					lowerCAmelCase__      )	-> None:
								if item not in self.pos_map:
									return
								a      :		Union[str, Any]	=				self.pos_map[item]
								a      :		str	=				[item, self.key(lowerCAmelCase__      )]
								# Make sure heap is right in both up and down direction.
								# Ideally only one of them will make any change.
								self._heapify_up(lowerCAmelCase__      )
								self._heapify_down(lowerCAmelCase__      )






							def     __a   (   self      ,					lowerCAmelCase__      )	-> None:
								if item not in self.pos_map:
									return
								a      :		str	=				self.pos_map[item]
								del self.pos_map[item]
								a      :		Optional[Any]	=				self.arr[self.size - 1]
								a      :		Union[str, Any]	=				index
								self.size -= 1
								# Make sure heap is right in both up and down direction. Ideally only one
								# of them will make any change- so no performance loss in calling both.
								if self.size > index:
									self._heapify_up(lowerCAmelCase__      )
									self._heapify_down(lowerCAmelCase__      )






							def     __a   (   self      ,					lowerCAmelCase__      ,					lowerCAmelCase__      )	-> None:
								a      :		Optional[Any]	=				len(self.arr      )
								if arr_len == self.size:
									self.arr.append([item, self.key(lowerCAmelCase__      )]      )
								else:
									a      :		str	=				[item, self.key(lowerCAmelCase__      )]
								a      :		Tuple	=				self.size
								self.size += 1
								self._heapify_up(self.size - 1      )






							def     __a   (   self      )	-> tuple | None:
								return self.arr[0] if self.size else None






							def     __a   (   self      )	-> tuple | None:
								a      :		Optional[Any]	=				self.get_top()
								if top_item_tuple:
									self.delete_item(top_item_tuple[0]      )
								return top_item_tuple






def       _SCREAMING_SNAKE_CASE		(	) ->None:






	'''simple docstring'''








if __name__ == "__main__":
		import doctest

		doctest.testmod()









"""simple docstring"""




from __future__ import annotations






def       _SCREAMING_SNAKE_CASE		(	_lowercase						:    list[int]    ,       _lowercase						:    int					) ->int:






	'''simple docstring'''






	if len(_lowercase					) < k or k < 0:
		raise ValueError("Invalid Input"					)
	a      :		Optional[Any]	=				sum(array[:k]					)
	for i in range(len(_lowercase					) - k					):
		a      :		Optional[Any]	=				current_sum - array[i] + array[i + k]
		a      :		Union[str, Any]	=				max(_lowercase    ,       _lowercase					)
	return max_sum


if __name__ == "__main__":
		from doctest import testmod
		from random import randint

		testmod()
		a						: Any     	=			[randint(-1000, 1000) for i in range(100)]
		a						: List[str]     	=			randint(0, 110)
		print(F'''The maximum sum of {k} consecutive elements is {max_sum_in_array(array,k)}''')


