#3259. [ABC177C] 两两乘积之和 Sum of product of pairs

[ABC177C] 两两乘积之和 Sum of product of pairs

[ABC177C] Sum of product of pairs

题目描述

给定 NN 个整数 A1,…,ANA_1,\ldots,A_N。

请计算满足 1≤i<j≤N1 \leq i < j \leq N 的所有组合 (i,j)(i, j) 的 Ai×AjA_i \times A_j 之和,并对 109+710^9+7 取模。

输入格式

输入通过标准输入按以下格式给出。

NN A1A_1 A2A_2 …\ldots ANA_N

输出格式

请输出 ∑i=1N−1∑j=i+1NAiAj\sum_{i=1}^{N-1}\sum_{j=i+1}^{N} A_i A_j 对 109+710^9+7 取模的结果。

3

1 2 3
11
4

141421356 17320508 22360679 244949
437235829

提示

限制条件

  • 2≤N≤2×1052 \leq N \leq 2 \times 10^5
  • 0≤Ai≤1090 \leq A_i \leq 10^9
  • 输入均为整数

样例说明 1

1×2+1×3+2×3=111 \times 2 + 1 \times 3 + 2 \times 3 = 11。

由 ChatGPT 4.1 翻译 原题链接: https://atcoder.jp/contests/abc177/tasks/abc177_c

Statistics

Related

In following homework:

国庆5下午