Python3: using heap
\n\n# Code\npython3\nclass Solution:\n    def unmarkedSumArray(self, nums: List[int], queries: List[List[int]]) -> List[int]:\n        heap = []\n        for i,
\n\n# Code\n```python3\nclass Solution:\n    def unmarkedSumArray(self, nums: List[int], queries: List[List[int]]) -> List[int]:\n        heap = []\n        for i,num in enumerate(nums):\n            heappush(heap, [num,i])\n        marked_index = set()\n        accumulation = sum(nums)\n        result = []\n        \n        for each in queries:\n            i,k = each\n            if i not in marked_index:\n                marked_index.add(i)\n                accumulation -= nums[i]\n            while k and heap:\n                num, index = heappop(heap) \n                if index not in marked_index:\n                    marked_index.add(index)\n                    k -= 1\n                    accumulation -= nums[index]\n            result.append(accumulation)\n        return result\n```
['Python3']