Use an extra element for summation so we don't need to check boundary condition in the query.

```
class NumArray(object):
def __init__(self, nums):
"""
initialize your data structure here.
:type nums: List[int]
"""
self.sums = [0] * (len(nums) + 1)
for i in xrange(len(nums)):
self.sums[i+1] = self.sums[i] + nums[i]
def sumRange(self, i, j):
"""
sum of elements nums[i..j], inclusive.
:type i: int
:type j: int
:rtype: int
"""
return self.sums[j+1] - self.sums[i]
```