You should already be familiar with the A +B problem and the following is an upgraded version. There is an array whose length is n. Captain Huang has Q queries. In each query, she may ask the sum of elements whose index is in the Interval [L,R].
The first line has two integer n and Q (1<n<1e5,1<Q<1e5) which represent the length of array and the number of queries respectively. Next line supplies n integer as an array. And the following Q lines represent queries. In each query, there are two integers L, R (1<=L<=R<=n).
For each query, output the sum of elementswhose index is in the Interval [L,R].
5 3 1 2 3 4 5 1 3 1 5 3 4
6 15 7