best ever solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nfrom typing import List\n\nclass Solution:\n    def unmarkedSumArray(self, nums: List[int], queries: List[List[int]]) -> List[int]:\n        total_sum = sum(nums)\n        marked = set()\n        answer = []\n        sorted_nums = sorted(enumerate(nums), key=lambda x: (x[1], x[0]))\n\n        next_unmarked = 0\n\n        for index, k in queries:\n            # Mark the specified element if it\'s not already marked.\n            if index not in marked:\n                marked.add(index)\n                total_sum -= nums[index]\n\n            while k > 0 and next_unmarked < len(nums):\n                while next_unmarked < len(nums) and sorted_nums[next_unmarked][0] in marked:\n                    next_unmarked += 1\n\n                if next_unmarked < len(nums):\n                    marked.add(sorted_nums[next_unmarked][0])\n                    total_sum -= sorted_nums[next_unmarked][1]\n                    next_unmarked += 1\n                    k -= 1\n\n            answer.append(total_sum)\n\n        return answer\n\n```
['Python3']