input: from typing import List
  
  def sum_of_unmarked_elements(nums: List[int], queries: List[List[int]]) -> List[int]:
      """
      Given a zero-indexed array of positive integers named nums, perform a series of mark operations.
  
      You are also provided with a 2D list of queries, where each query consists of [index_i, k_i].
  
      Initially, no element in the array is marked.
  
      For each of the m queries, perform the following steps:
      
      1. Mark the element at index_i if it is currently unmarked.
      2. Subsequently, mark k_i unmarked elements with the smallest values in the array. If there are ties, mark those with the smallest indices. If fewer than k_i unmarked elements exist, mark all available unmarked elements.
  
      Return a list where each entry is the sum of unmarked elements in the array after performing each query.
  
      Examples:
      >>> nums = [1, 2, 2, 1, 2, 3, 1], queries = [[1,2],[3,3],[4,2]]
      [8, 3, 0]
      >>> nums = [1, 4, 2, 3], queries = [[0,1]]
      [7]
  
      Constraints:
      - n is the length of nums
      - m is the number of queries
      - 1 <= m <= n <= 10^5
      - 1 <= nums[i] <= 10^5
      - Each query consists of exactly 2 elements
      - 0 <= index_i, k_i <= n - 1
      """
output:     n = len(nums)
      unmarked = set(range(n))  # Initialize all indices as unmarked
      result = []
  
      for index_i, k_i in queries:
          # Mark the element at index_i
          if index_i in unmarked:
              unmarked.remove(index_i)
  
          # Mark k_i unmarked elements with the smallest values
          unmarked_list = sorted(unmarked, key=lambda x: (nums[x], x))[:k_i]
          for idx in unmarked_list:
              unmarked.remove(idx)
  
          # Calculate the sum of unmarked elements
          current_sum = sum(nums[i] for i in unmarked)
          result.append(current_sum)
  
      return result