Problem12239--前缀和

12239: 前缀和

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MiB

Description



输入一个长度为 lns="http://www.w3.org/1998/Math/MathML">n 的整数序列。

接下来再输入 lns="http://www.w3.org/1998/Math/MathML">m 个询问,每个询问输入一对 lns="http://www.w3.org/1998/Math/MathML">l,r

对于每个询问,输出原序列中从第 lns="http://www.w3.org/1998/Math/MathML">l 个数到第 lns="http://www.w3.org/1998/Math/MathML">r 个数的和。

						

Input

第一行包含两个整数 lns="http://www.w3.org/1998/Math/MathML">n 和 lns="http://www.w3.org/1998/Math/MathML">m

第二行包含 lns="http://www.w3.org/1998/Math/MathML">n 个整数,表示整数数列。

接下来 lns="http://www.w3.org/1998/Math/MathML">m 行,每行包含两个整数 lns="http://www.w3.org/1998/Math/MathML">l 和 lns="http://www.w3.org/1998/Math/MathML">r,表示一个询问的区间范围。


Output

共 lns="http://www.w3.org/1998/Math/MathML">m 行,每行输出一个询问的结果


Sample Input Copy

5 3
2 1 3 6 4
1 2
1 3
2 4 

Sample Output Copy

3
6
10

HINT

数据范围
1≤l≤r≤n,
1≤n,m≤100000
-1000≤数列中元素的值≤1000



Source/Category