Once you have the prefix array, queries are trivial:
function sumRange(left, right):
return prefix[right + 1] - prefix[left]
Time: . Space: per query. The offset handles the convention that is the sum of elements before index . If this feels awkward, trace through an example until it clicks.