J. Jumping Reaction
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Today, in chemistry class, Maximiliano is studying highly explosive substances, specifically those that produce a "Jumping reaction". Each substance has a jumping energy which is represented with an integer number. When two substances having jumping energies $$$a$$$ and $$$b$$$ mix, the reaction will have $$$ab$$$ jumping energy.

During the class, the teacher mentioned an interesting property of the substances: when $$$K$$$ substances are mixed, the reaction jumping energy will be the sum of the reactions that would happen if all possible pairs were mixed. For example if $$$K = 3$$$ and the mixed substances have jumping energies $$$a$$$, $$$b$$$, and $$$c$$$, their resulting energy would be $$$ab$$$ + $$$ac$$$ + $$$bc$$$.

Maximiliano will perform $$$Q$$$ experiments using some of the $$$N$$$ substances he can reach in class, on each experiment Maximiliano will take all the substances in the range $$$[L, R]$$$ and mix them. He is afraid that the resulting jumping energy may make him jump off the lab, so He asked for your help to tell him what would be the jumping energy of the reaction on each of the experiments he wants to perform.

Help him solve his questions!

Input

The first line of input contains two numbers $$$N$$$ and $$$Q$$$ ($$$2 \leq N, Q \leq 10^6$$$) that represents the number of substances and the number ofexperiments.

The next line contains $$$N$$$ integer numbers $$$A_i$$$ ($$$1 \leq A_i \leq 10^6$$$) representing the jumping energy of the $$$i$$$-th substance.

The next $$$Q$$$ lines will have two integers each, $$$L$$$ and $$$R$$$ ($$$1 \leq L \le R \leq N$$$) representing the range of the question.

Output

Print $$$Q$$$ lines where each line represents the resulting jumping energy of the $$$i$$$-th experiment. Because this number can be very large, print it modulo $$$10^9 + 7$$$

Examples
Input
5 3
1 2 3 4 5
1 2
1 5
3 5
Output
2
85
47
Input
10 2
3 1 5 2 3 1 5 6 1 1
7 10
2 3
Output
53
5