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_1 : List [ List [ int ] ] ) -> int :
      var_2 = 100010
      var_3 = [ 0 ] * var_2
      for var_4 , var_5 in var_1 :
          var_3 [ var_4 ] += 1
          var_3 [ var_5 + 1 ] -= 1
      for var_6 in range ( 1 , var_2 ) :
          var_3 [ var_6 ] += var_3 [ var_6 - 1 ]
      var_0.sort ( )
      var_3.sort ( )
      var_6 , var_7 , var_8 = var_2 - 1 , len ( var_0 ) - 1 , 0
      while var_6 > 0 and var_3 [ var_6 ] > 0 :
          var_8 += var_3 [ var_6 ] * var_0 [ var_7 ]
          var_6 -= 1
          var_7 -= 1
      return var_8 % 1000000007
  