comefrom: <doocs>2145.Count the Hidden Sequences_1.py
code: def numberOfArrays( differences: List[int], lower: int, upper: int) -> int:
      num = mi = mx = 0
      for d in differences:
          num += d
          mi = min(mi, num)
          mx = max(mx, num)
      return max(0, upper - lower - (mx - mi) + 1)
masked: def sample_funcname ( var_0 : List [ int ] , var_3 : int , var_4 : int ) -> int :
      var_8 = var_5 = var_6 = 0
      for var_9 in var_0 :
          var_8 += var_9
          var_5 = min ( var_5 , var_8 )
          var_6 = max ( var_6 , var_8 )
      return max ( 0 , var_4 - var_3 - ( var_6 - var_5 ) + 1 )
  