Given an array, A, containing n integers, a1,a2,a3,...an, you have to answer q queries.
For each query you will be given a one-indexed range [l,r], l≤r, and your answer to each query should be: ∑ri=l(r−i+1).a[i]
For example, if A=[6,10,−9,11,12], for l=2, and r=5:
(5−2+1)∗10+(5−3+1)∗−9+(5−4+1)∗11+(5−5+1)∗12=
4∗10+3∗−9+2∗11+1∗12=47
NOTE: The answer to a query may not fit a 32-bit integer type.
Input format
Output format
Your program should output q lines, and the ithof these lines should be the answer to the ith query.
Constraints
1≤n,q≤105−107≤Ai≤1071≤li≤ri≤n
A in the sample is [6,10,−9,11,12], and there are 3 queries:
The first query l=2 and r=5 is explained in the sample.
In the second query l=3 and r=4, it can be evaluated as (4−3+1)∗−9+(4−4+1)∗11=2∗−9+1∗11=−7.
In the third query l=3 and r=3, it can be evalued as (3−3+1)∗−9=1∗−9=−9.