comefrom: <doocs>1589.Maximum Sum Obtained of Any Permutation_1.py
code: def maxSumRangeQuery( nums: List[int], requests: List[List[int]]) -> int:
      n = 100010
      delta = [0] * n
      for start, end in requests:
          delta[start] += 1
          delta[end + 1] -= 1
      for i in range(1, n):
          delta[i] += delta[i - 1]
      nums.sort()
      delta.sort()
      i, j, res = n - 1, len(nums) - 1, 0
      while i > 0 and delta[i] > 0:
          res += delta[i] * nums[j]
          i -= 1
          j -= 1
      return res % 1000000007
masked: def sample_funcname ( var_0 : List [ int ] , var_3 : List [ List [ int ] ] ) -> int :
      var_5 = 100010
      var_7 = [ 0 ] * var_5
      for var_8 , var_9 in var_3 :
          var_7 [ var_8 ] += 1
          var_7 [ var_9 + 1 ] -= 1
      for var_12 in range ( 1 , var_5 ) :
          var_7 [ var_12 ] += var_7 [ var_12 - 1 ]
      var_0.sort ( )
      var_7.sort ( )
      var_12 , var_15 , var_16 = var_5 - 1 , len ( var_0 ) - 1 , 0
      while var_12 > 0 and var_7 [ var_12 ] > 0 :
          var_16 += var_7 [ var_12 ] * var_0 [ var_15 ]
          var_12 -= 1
          var_15 -= 1
      return var_16 % 1000000007
  