AtCoder Beginner Contest 177
C
Sum of product of pairs
AtCoder
⌀ 386
原题
← BD →
翻译中…

Problem Statement

翻译中…

Given are $N$ integers $A_1,\ldots,A_N$.

翻译中…

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

翻译中…

Constraints

翻译中…
  • $2 \leq N \leq 2\times 10^5$
  • $0 \leq A_i \leq 10^9$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 \ldots A_N

翻译中…

Output

翻译中…

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

翻译中…

样例

Input #1
3
1 2 3
Output #1
11
We have $1 \times 2 + 1 \times 3 + 2 \times 3 = 11$.
Input #2
4
141421356 17320508 22360679 244949
Output #2
437235829
题目信息
题号
abc177_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。