#3105. Sum of product of pairs

0

Sum of product of pairs

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+7)(10^9+7) 取模。

输入格式

输入从标准输入按以下格式给出: NN A1A_1 …\ldots ANA_N

输出格式

打印 ∑i=1N−1∑j=i+1NAiAj\sum_{i=1}^{N-1}\sum_{j=i+1}^{N} A_i A_j,对 (109+7)(10^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×2+1×3+2×3=111 \times 2 + 1 \times 3 + 2 \times 3 = 11.

标签: AtCoder|abc177C

来源

AtCoder|abc177C