input: from typing import List
  
  def max_non_adjacent_sum_with_updates(nums: List[int], queries: List[List[int]]) -> int:
      """
      Given an array nums consisting of integers and a 2D array queries where queries[i] = [pos_i, x_i],
  
      For each query i, first update nums[pos_i] to x_i, then compute the result for query i, which is the maximum sum of 
      a subsequence of nums with no two adjacent elements selected.
  
      Return the sum of the results for all queries modulo 10^9 + 7, since the final answer may be very large.
  
      A subsequence is derived from another array by deleting some or no elements without altering the order of the remaining elements.
  
      Examples:
      >>> nums = [3,5,9], queries = [[1,-2],[0,-3]]
      21
      >>> nums = [0,-1], queries = [[0,-5]]
      0
  
      Constraints:
      1 <= nums.length <= 5 * 10^4
      -10^5 <= nums[i] <= 10^5
      1 <= queries.length <= 5 * 10^4
      queries[i] == [pos_i, x_i]
      0 <= pos_i <= nums.length - 1
      -10^5 <= x_i <= 10^5
      """
output:     
      MOD = 10**9 + 7
      
      def max_non_adjacent_sum(arr: List[int]) -> int:
          incl, excl = 0, 0
          for num in arr:
              new_excl = max(incl, excl)
              incl = excl + num
              excl = new_excl
          return max(incl, excl)
      
      total_sum = 0
      for pos, value in queries:
          nums[pos] = value
          current_sum = max_non_adjacent_sum(nums)
          total_sum = (total_sum + current_sum) % MOD
      
      return total_sum
  