Type: Default 1000ms 256MiB

平方的和

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

给定 nn 个整数 a1,a2,,ana_1, a_2, \dots, a_n​ ,请求出两两数字和的平方的和,也就是

1i<jn(ai+aj)2\sum_{1 \leq i < j \leq n} (a_i + a_j)^2

由于这个数字比较大,输出答案模 109+710^9 + 7 的余数。

Format

Input

第一行单个整数 nn

第二行nn个整数 a1,a2,,ana_1, a_2, \dots, a_n

Output

一行一个整数表示答案

Samples

样例输入

3
1 2 3

样例输出

50

样例解释

(1+2)2+(1+3)2+(2+3)2(1 + 2)^2 + (1 + 3)^2 + (2 + 3)^2

Limitation

  • 30%: 1n1001 \leq n \leq 100, 0ai1000 \leq a_i \leq 100
  • 60%: 1n1041 \leq n \leq 10^4, 0ai1040 \leq a_i \leq 10^4
  • 100%: 1n2×1051 \leq n \leq 2 \times 10^5, 0ai2×1050 \leq a_i \leq 2 \times 10^5

1s, 512MiB for each test case.

20250515周赛

Not Attended
Status
Done
Rule
IOI
Problem
6
Start at
2025-5-29 16:45
End at
2025-5-29 18:15
Duration
1.5 hour(s)
Host
Partic.
23