Borrowed Query Convention

The USACO Guide builds prefix sums with a leading zero, so psums[k] is the sum of the first k elements, and its sample code answers a query pair l, r with psums[r] - psums[l].

def psum(arr):
    psums = [0]
    for i in arr:
        psums.append(psums[-1] + i)
    return psums

arr = [5, 2, 9, 1, 7]
psums = psum(arr)          # [0, 5, 7, 16, 17, 24]

l, r = 2, 2                # 0-indexed, inclusive on both ends
print(psums[r] - psums[l])

The query here is written 0-indexed and inclusive, so the intended answer is arr[2] == 9. What is printed, and what is the correct expression for this convention?

A

It prints 0, and that is correct: [2, 2] is a half-open range, so it covers no elements

B

It prints 0; the correct expression is psums[r + 1] - psums[l]

C

It prints 0; the correct expression is psums[r] - psums[l - 1]

D

It prints 9; the code is already right, because the leading zero shifts psums by one