#c22701. 前缀和
前缀和
Prefix Sum
Problem Description
You are given a sequence and queries.
Each query gives two numbers , and asks for the value of .
Input Format
The first line contains two integers .
The next line contains integers .
The following lines each contain two integers .
Output Format
Output lines, each containing an integer: the answer.
Sample Input
5 5
7 6 4 7 4
2 5
1 3
3 5
1 2
2 4
Sample Output
21
17
15
13
17
Constraints
For of the data, $1 \leq n, m \leq 10^5, 1 \leq a_i \leq 10^9, 1 \le l \le r \le n$.