```
class NumArray(object):
def __init__(self, nums):
"""
:type nums: List[int]
"""
self.cumsum = [sum(nums[:i]) for i in range(1,len(nums)+1)]
def sumRange(self, i, j):
"""
:type i: int
:type j: int
:rtype: int
"""
return self.cumsum[j] - self.cumsum[i-1] if i > 0 else self.cumsum[j]
```