408027: GYM102964 A Krosh and new sum

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Krosh and new sumtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Krosh has an array of $$$n$$$ integers. Help him to calculate the following value: $$$\sum\limits_{i=1}^n \sum\limits_{j=i+1}^n |a_i - a_j| * (a_i + a_j)$$$. Output it modulo $$$10^9+7$$$.

Input

In the first line you are given number $$$1 \le n \le 2 * 10^5$$$. In the second line you are given array of $$$n$$$ non-negative integers $$$1 \le a_i \le 10^8$$$.

Output

Output answer modulo $$$10^9+7$$$.

ExamplesInput
5
2 3 4 5 1
Output
120
Input
2
100000000 100000000
Output
0
Input
10
1 100000000 1 100000000 100000000 1 1 100000000 100000000 1
Output
249999989

加入题单

算法标签: