def METHOD_NAME(self, val):
    if val < self.min_deque[0]:
        raise ValueError("Wrong value")
    elif val == self.min_deque[0]:
        self.min_deque.popleft()
    if val > self.max_deque[0]:
        raise ValueError("Wrong value")
    elif val == self.max_deque[0]:
        self.max_deque.popleft()