#P8218. 【深进1.例1】求区间和
【深进1.例1】求区间和
Problem Description
Given a sequence consisting of positive integers and intervals , find the sum of elements in each of the intervals.
Input Format
The first line contains a positive integer , representing the length of the sequence.
The second line contains positive integers .
The third line contains a positive integer , representing the number of intervals.
The next lines each contain two positive integers , satisfying .
Output Format
Output lines. The -th line contains a positive integer, representing the answer to the -th query.
4
4 3 2 1
2
1 4
2 3
10
5
Hint
Sample Explanation
The sum of the st to the th numbers is . The sum of the nd to the rd numbers is .
Constraints
For of the testdata: .
For of the testdata: , .
Translated by ChatGPT 5