input: Write a Python function that takes a list of positive integers `nums` of size `n`, and a 2D list of queries `queries` of size `m`. Each query in `queries` is a two-element list `[index_i, k_i]`. Initially, all elements in the array are unmarked. For each query, mark the element at `index_i` if it is unmarked, then mark `k_i` unmarked elements with the smallest values (prioritizing the smallest indices in case of ties). If fewer than `k_i` unmarked elements exist, mark all the remaining unmarked elements. Return a list of size `m` where each element is the sum of unmarked elements after the corresponding query.
  
  Example:
  
  >>> nums = [1,2,2,1,2,3,1]
  >>> queries = [[1,2],[3,3],[4,2]]
  >>> unmarked_sum_array(nums, queries)
  [8, 3, 0]
  
  >>> nums = [1,4,2,3]
  >>> queries = [[0,1]]
  >>> unmarked_sum_array(nums, queries)
  [7]
  
  
  Constraints:
  - `n == len(nums)`
  - `m == len(queries)`
  - `1 <= m <= n <= 10^5`
  - `1 <= nums[i] <= 10^5`
  - `len(queries[i]) == 2`
  - `0 <= index_i, k_i <= n - 1`
output: def unmarked_sum_array(nums, queries):
      n = len(nums)
      marked = [False] * n
      result = []
  
      for index_i, k_i in queries:
          if not marked[index_i]:
              marked[index_i] = True
  
          unmarked = sorted((num, idx) for idx, num in enumerate(nums) if not marked[idx])
          count = 0
          for num, idx in unmarked:
              if count >= k_i:
                  break
              marked[idx] = True
              count += 1
  
          current_sum = sum(num for i, num in enumerate(nums) if not marked[i])
          result.append(current_sum)
  
      return result