Sum of Subarrays#12232

Sum of Subarrays

1 second
128 megabytes
Medium

You are given an integer sequence a = (a_1, a_2, \ldots, a_n) of length .

There are queries, and for each query you need to find the answer. In the -th query, two integers l_i and r_i are given, and you must compute the value:

\sum_{l = l_i}^{r_i} \sum_{r = l}^{r_i} \sum_{j = l}^{r} a_j.

Input

The first line contains two integers and q~(1 \le n, q \le 3 \times 10^5).

The second line contains integers a_1, a_2, \ldots, a_n~(1 \le a_i \le 100).

Then follow lines, each containing two integers l_i, r_i~(1 \le l_i \le r_i \le n).

Output

Print lines. In the -th line, output a single integer — the answer to the -th query.

Examples

Example 1

Loading
Loading