The daily earnings of a company are known for days, numbered to . Your task is to answer questions: for a period given by its first day and last day , what are the total earnings of the company in that period?
Input
The first line contains a single integer - the number of testcases.
- The first line of each testcase contains an integer - the number of days.
- The next line contains integers - the earnings for each day.
- The next line contains an integer - the number of questions.
- Each of the next lines contains two integers and - the first and the last day of a period.
Output
For every question print a single line with the total earnings from day to day .
Example
1 5 1 2 3 4 5 3 0 4 1 3 2 2
15 9 3
The whole period earns , days to earn , and day alone earns .
Constraints
The earnings of a single day are between and .
Both the sum of and the sum of over all testcases are at most .
This problem was adapted, with permission, from Zbirovi segmenata, authored by Društvo matematičara Srbije and Fondacija Petlja.