[Python] heapq
python\nclass Solution:\n    def unmarkedSumArray(self, nums: List[int], queries: List[List[int]]) -> List[int]:\n        s = 0\n        h = []\n        m = set
```python\nclass Solution:\n    def unmarkedSumArray(self, nums: List[int], queries: List[List[int]]) -> List[int]:\n        s = 0\n        h = []\n        m = set()\n\n        for i in range(len(nums)):\n            s += nums[i]\n            heappush(h, (nums[i], i))\n\n        a = []\n        for i, k in queries:\n            if i not in m:\n                m.add(i)\n                s -= nums[i]\n\n            while h and k > 0:\n                _, i = heappop(h)\n                if i not in m:\n                    m.add(i)\n                    s -= nums[i]\n                    k -= 1\n\n            a.append(s)\n\n        return a\n```
['Heap (Priority Queue)', 'Python']