#abc177c. [abc177_c]Sum of product of pairs

[abc177_c]Sum of product of pairs

Problem Statement

Given are NN integers A1,ldots,ANA_1,\\ldots,A_N.

Find the sum of AitimesAjA_i \\times A_j over all pairs (i,j)(i,j) such that 1leqi<jleqN1\\leq i < j \\leq N, modulo (109+7)(10^9+7).

Constraints

  • 2leqNleq2times1052 \\leq N \\leq 2\\times 10^5
  • 0leqAileq1090 \\leq A_i \\leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN A1A_1 ldots\\ldots ANA_N

Output

Print sumi=1N1sumj=i+1NAiAj\\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} A_i A_j, modulo (109+7)(10^9+7).


Sample Input 1

3
1 2 3

Sample Output 1

11

We have 1times2+1times3+2times3=111 \\times 2 + 1 \\times 3 + 2 \\times 3 = 11.


Sample Input 2

4
141421356 17320508 22360679 244949

Sample Output 2

437235829