【ZZULI】[1724]candy

题目描述

Kimi has a lot of candies, and divides them into piles, where the _i_th pile contains A__i candies. Each time Kimi will choose an interval [l,r], and calculate the total amount of A__l,A__l+1,…,A__r. It’s a hard task, and you’re required to solve it.

输入

An integer T(_T_≤10) will exist in the first line of input, indicating the number of test cases. Each test case begins with the number of piles N(1≤_N_≤105). The second line contains N integers A__i(1≤_A__i_≤100), where A__i stands for the number of candies in the i_th pile. The next line is the number of queries M(1≤_M_≤105). The next M lines, each with two integers l,r(1≤_l_≤_r_≤_N), describe the queried intervals.

输出

For each test case, output the total amount of candies in the queried interval.

样例输入

1
5
1 2 4 5 9
3
1 2
2 4
4 5

样例输出

3
11
14

来源/分类