#P7448. [Ynoi2007] rdiq
[Ynoi2007] rdiq
Problem Description
Given a sequence of length .
There are queries. For each query, an interval is given. Compute .
Input Format
The first line contains an integer .
The second line contains integers, where the -th integer denotes the value at position of the sequence.
The third line contains an integer .
Then follow lines, each line contains two integers separated by two spaces, denoting , which represent a query. It is guaranteed that .
Output Format
Output lines. The -th line contains one integer, representing the answer to the -th query.
5
2 1 3 2 1
4
2 4
1 5
3 5
2 2
1
3
3
0
Hint
Idea: nzhtl1477, Solution: nzhtl1477&ccz181078, Code: ccz181078, Data: w33z8kqrqk8zzzx33&nzhtl1477.
For the first query, the set is .
For the second and third queries, the set is .
For the fourth query, the set is an empty set.
For of the testdata, the Constraints are , , .
Translated by ChatGPT 5