Loading...
Help Akib!!!
Time: 1 s
Memory: 500 MB
 
Akib wants to look at an array.

He is reviewing a list of n integers and needs to manage q queries. Each query is about finding the total sum of values within a specific range [a, b] of the provided array.Considering he can't figure this out on his own, he's looking for assistance to correctly compute and present the sum for each query.
 
Input
The first input line has two integers n and q, the number of values and queries respectively.
The second line has n integers x1,x2,…,xn: the array values.

Finally, there are q lines describing the queries. Each line has two integers a and b: what is the sum of values in range [a,b]?
Constraint
1 ≤ n,q ≤ 2*10^5
1 ≤ xi ≤ 10^9
1 ≤ a ≤ b ≤ n
Output

Print the result of each query.
Examples
Input
Output
8 4
3 2 4 5 1 1 5 3
2 4
5 6
1 8
3 3
11
2
24
4
Problem Info
Problem ID 280
Time Limit 1000 ms
Memory Limit 512000 KB
Moderators Akiiib , ApuYe , SajidAbdullah , nirjoy_139 , remon60 , piru72
Statistics
Submit
You need to Login or Registration for submit your solution