Range Sum Queries
Answer queries: each asks for (1-based). Re-adding for every query is too slow — precompute prefix sums.
Input
, the integers, , then lines with and .
Output
One sum per line.
Constraints
,
Sample 1
Input
5 1 2 3 4 5 3 1 5 2 3 4 4
Output
15 5 4