Limits 1s, 512 MB

Little Oishee loves to watch TV. But her mother, who is a math teacher, doesn't like this at all. She thinks this way her daughter is being spoiled. So, she gave her this homework to keep her away from watching too much TV.

Let's define a function,

F(S)=i=1nj=i+1nAiAjF(S) = \sum_{i=1}^{n}\sum_{j=i+1}^{n} \left | A_{i} - A_{j} \right |

Now, given a set SS with nn integers, she needs to find the cumulative sum of F(a)F(a) for all aa, where aa is any non-empty subset of SS.

Little Oishee who is very clever took a paper and pen and tried this for some random small sets and thought this wasn't difficult. So, she went to her mother and told her "Ammu etato easy peasy." Her mother laughed at her and gave her some big sets of numbers and said "Ok dear, finish these easy peasy home works first then you may go and watch TV".

Then the little one realized, this wasn't as easy as she thought. ICC Champions Trophy is going on. Little Oishee is really fond of cricket and doesn't want to miss even a single match. So, as always she got depressed and sat on her bed with a sad face. Now, you are her friend and a cunning computer programmer. Can you do this task on behalf of little Oishee? Then both of you can enjoy the match together!

Input

The first line contains one integer nn (1n1051 ≤ n ≤ 10^5).

Second line contains nn integers A1A_1, A2A_2, ..., AnA_n (1Ai1091 ≤ A_i ≤ 10^9) denoting the elements of the set.

Output

Print the answer modulo 10000000071000000007 (109+710^9 + 7).

Samples

InputOutput
2
3 7
4

In the first case the subsets are {(3),(7),(3,7)}\{ ( 3 ), ( 7 ), ( 3, 7 ) \}. For (3)( 3 ) and (7)( 7 ) the F()F() is 0, and for (3,7)( 3, 7 ) it is 4. So the answer is (0+0+4)=4( 0 + 0 + 4 ) = 4.

InputOutput
3
1 3 5
16

In the second case the subsets (with at least size greater than 1) are {(1,3),(1,5),(3,5),(1,3,5)}\{ ( 1, 3 ) , ( 1, 5 ), ( 3, 5 ) , ( 1, 3, 5 ) \} answer the F()F() value for them are (2+4+2+8)=16(2 + 4 + 2 + 8) = 16.


Submit

Login to submit.

Statistics

76% Solution Ratio
Matrix.codeEarliest, Jun '17
tuhin107494Fastest, 0.0s
fire_tornadoLightest, 393 kB
subhashis_cseShortest, 423B
Toph uses cookies. By continuing you agree to our Cookie Policy.