```
class NumArray(object):
def __init__(self, nums):
s = 0
self.num_sums = [0]
for n in nums:
s += n
self.num_sums.append(s)
def sumRange(self, i, j):
return self.num_sums[j + 1] - self.num_sums[i]
```