[Python3] Deque and SortedList
```\nfrom sortedcontainers import SortedList\n\n\nclass MKAverage:\n\n    def init(self, m: int, k: int):\n        self.m = m\n        self.k = k\n        self.
```\nfrom sortedcontainers import SortedList\n\n\nclass MKAverage:\n\n    def __init__(self, m: int, k: int):\n        self.m = m\n        self.k = k\n        self.q = deque()\n        self.mid = SortedList()\n        self.total = 0\n\n    def addElement(self, num: int) -> None:\n        self.q.append(num)\n        self.mid.add(num)\n        self.total += num\n        if len(self.q) > self.m:\n            x = self.q.popleft()\n            self.mid.remove(x)\n            self.total -= x\n\n    def calculateMKAverage(self) -> int:\n        if len(self.q) < self.m:\n            return -1\n        remove = sum(self.mid[:self.k]) + sum(self.mid[-self.k:])\n        return int((self.total - remove) / (self.m - self.k * 2))\n
[]