



"""simple docstring"""




import numpy as np






class 	UpperCAmelCase_  :



      def __init__(     self     :	Tuple     ,	A     :	List[Any]=5     ,	A     :	Dict=5						):
           _UpperCAmelCase			:	Tuple								=    depth
           _UpperCAmelCase			:	Optional[int]								=    0
           _UpperCAmelCase			:	Optional[Any]								=    None
           _UpperCAmelCase			:	Optional[int]								=    None
           _UpperCAmelCase			:	Optional[Any]								=    min_leaf_size
           _UpperCAmelCase			:	Optional[int]								=    None



      def 						snake_case_					(     self     :	int     ,	A     :	Any     ,	A     :	int						):
           if labels.ndim != 1:
                print("Error: Input labels must be one dimensional"						)

           return np.mean((labels - prediction) ** 2						)



      def 						snake_case_					(     self     :	Tuple     ,	A     :	str     ,	A     :	Union[str, Any]						):
           if x.ndim != 1:
                print("Error: Input data set must be one dimensional"						)
                return
           if len(A						) != len(A						):
                print("Error: X and y have different lengths"						)
                return
           if y.ndim != 1:
                print("Error: Data set labels must be one dimensional"						)
                return

           if len(A						) < 2 * self.min_leaf_size:
                _UpperCAmelCase			:	Optional[Any]								=    np.mean(A						)
                return

           if self.depth == 1:
                _UpperCAmelCase			:	int								=    np.mean(A						)
                return

           _UpperCAmelCase			:	Union[str, Any]								=    0
           _UpperCAmelCase			:	int								=    self.mean_squared_error(A     ,	np.mean(A						)						) * 2
           for i in range(len(A						)						):
                if len(x[:i]						) < self.min_leaf_size:
                     continue
                elif len(x[i:]						) < self.min_leaf_size:
                     continue
                else:
                     _UpperCAmelCase			:	Dict								=    self.mean_squared_error(x[:i]     ,	np.mean(y[:i]						)						)
                     _UpperCAmelCase			:	str								=    self.mean_squared_error(x[i:]     ,	np.mean(y[i:]						)						)
                     _UpperCAmelCase			:	Any								=    error_left + error_right
                     if error < min_error:
                          _UpperCAmelCase			:	str								=    i
                          _UpperCAmelCase			:	Any								=    error

           if best_split != 0:
                _UpperCAmelCase			:	Union[str, Any]								=    x[:best_split]
                _UpperCAmelCase			:	Tuple								=    y[:best_split]
                _UpperCAmelCase			:	Tuple								=    x[best_split:]
                _UpperCAmelCase			:	int								=    y[best_split:]

                _UpperCAmelCase			:	List[Any]								=    x[best_split]
                _UpperCAmelCase			:	Tuple								=    DecisionTree(
                    depth=self.depth - 1     ,	min_leaf_size=self.min_leaf_size						)
                _UpperCAmelCase			:	Dict								=    DecisionTree(
                    depth=self.depth - 1     ,	min_leaf_size=self.min_leaf_size						)
                self.left.train(A     ,	A						)
                self.right.train(A     ,	A						)
           else:
                _UpperCAmelCase			:	Optional[Any]								=    np.mean(A						)

           return



      def 						snake_case_					(     self     :	Any     ,	A     :	Union[str, Any]						):
           if self.prediction is not None:
                return self.prediction
           elif self.left or self.right is not None:
                if x >= self.decision_boundary:
                     return self.right.predict(A						)
                else:
                     return self.left.predict(A						)
           else:
                print("Error: Decision tree not yet trained"						)
                return None







class 	UpperCAmelCase_  :



      @staticmethod
      def 						snake_case_					(     A     :	Optional[int]     ,	A     :	str						):
           _UpperCAmelCase			:	Optional[Any]								=    float(0						)
           for label in labels:
                squared_error_sum += (label - prediction) ** 2

           return float(squared_error_sum / labels.size						)







def 						__snake_case						(      )  ->   Any:





     '''simple docstring'''

     _UpperCAmelCase			:	int								=    np.arange(-1.0						,  1.0						,  0.005				)
     _UpperCAmelCase			:	List[Any]								=    np.sin(SCREAMING_SNAKE_CASE__				)

     _UpperCAmelCase			:	str								=    DecisionTree(depth=10						,  min_leaf_size=10				)
     tree.train(SCREAMING_SNAKE_CASE__						,  SCREAMING_SNAKE_CASE__				)

     _UpperCAmelCase			:	Tuple								=    (np.random.rand(10				) * 2) - 1
     _UpperCAmelCase			:	List[str]								=    np.array([tree.predict(SCREAMING_SNAKE_CASE__				) for x in test_cases]				)
     _UpperCAmelCase			:	str								=    np.mean((predictions - test_cases) ** 2				)

     print("Test values: " + str(SCREAMING_SNAKE_CASE__				)				)
     print("Predictions: " + str(SCREAMING_SNAKE_CASE__				)				)
     print("Average error: " + str(SCREAMING_SNAKE_CASE__				)				)


if __name__ == "__main__":
 main()
 import doctest

 doctest.testmod(name="mean_squarred_error", verbose=True)




from __future__ import annotations


class        A_					:




      '''simple docstring'''


      def __init__(				self:       Union[str, Any]						,      a:       int				):
       __lowerCamelCase		:							List[Any]							=						data
       __lowerCamelCase		:							Optional[Any]							=						None



class        A_					:




      '''simple docstring'''


      def __init__(				self:       Dict				):
       __lowerCamelCase		:							Dict							=						None




      def      _snake_case	(				self:       Dict						,      a:       int				):
       __lowerCamelCase		:							List[Any]							=						Node(a				)
       __lowerCamelCase		:							Dict							=						self.head
       __lowerCamelCase		:							Optional[int]							=						new_node
       return self.head.data




      def      _snake_case	(				self:       Optional[Any]				):
       __lowerCamelCase		:							Union[str, Any]							=						self.head
       __lowerCamelCase		:							List[Any]							=						self.head
       if self.head:
        while fast_pointer and fast_pointer.next:
         __lowerCamelCase		:							Any							=						fast_pointer.next.next
         __lowerCamelCase		:							str							=						slow_pointer.next
        return slow_pointer.data
       else:
        print('No element found.'				)
        return None


if __name__ == "__main__":
       lowercase_           =	LinkedList()
       for _ in range(int(input().strip())):
              lowercase_           =	int(input().strip())
              link.push(data)
       print(link.middle_element())

