classBIT:def__init__(self,n:int): self.sums = [0] * (n +1)deflowbit(self,i:int):return i &-idefupdate(self,i:int,delta:int):while i <len(self.sums): self.sums[i]+= delta i += self.lowbit(i)defquery(self,i:int) ->int: res =0while i >0: res += self.sums[i] i -= self.lowbit(i)return resclassNumArray:def__init__(self,nums: List[int]): self.nums = nums self.tree =BIT(len(nums))for i inrange(len(self.nums)): self.tree.update(i +1, nums[i])defsumRange(self,left:int,right:int) ->int:return self.tree.query(right +1)- self.tree.query(left)# Your NumArray object will be instantiated and called as such:# obj = NumArray(nums)# param_1 = obj.sumRange(left,right)