Python Heap + hash map 
\n# Code\n```python3 []\nclass Solution:\n    def unmarkedSumArray(self, nums: List[int], q: List[List[int]]) -> List[int]:\n        m = len(q)\n        n = len(nums)\n\n        marked = defaultdict(int)\n        heap = []\n        total_sum = sum(nums)\n        output = []\n\n        for i,num in enumerate(nums):\n            pair = (num,i)\n            heapq.heappush(heap,pair)\n            \n        for i, query in enumerate(q):\n            index_to_mark = query[0]\n            elements_to_mark = query[1]\n            temp_sum = 0\n            if not index_to_mark in marked:\n                temp_sum+=nums[index_to_mark]\n                marked[index_to_mark]+=1\n            while heap and elements_to_mark:\n                pair = heapq.heappop(heap)\n                if pair[1] in marked:\n                    continue\n                else:\n                    temp_sum+=pair[0]\n                    marked[pair[1]]+=1\n                    elements_to_mark-=1\n            total_sum-=temp_sum\n            output.append(total_sum)\n        return output\n            \n        \n```
['Python3']