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$$$.
InputIn 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$$$.
OutputOutput answer modulo $$$10^9+7$$$.
ExamplesInput5 2 3 4 5 1Output
120Input
2 100000000 100000000Output
0Input
10 1 100000000 1 100000000 100000000 1 1 100000000 100000000 1Output
249999989