#B. C - Sum of product of pairs

    传统题 1000ms 256MiB

C - Sum of product of pairs

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

C - Sum of product of pairs

Score : $300$ points

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:

NN

A1A_1 \ldots ANA_N

Output

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


3
1 2 3
11

We have $1 \times 2 + 1 \times 3 + 2 \times 3 = 11$.


4
141421356 17320508 22360679 244949
437235829

2024寒假入门组刷题营(十四)

未参加
状态
已结束
规则
ACM/ICPC
题目
8
开始于
2024-2-14 13:30
结束于
2024-2-14 15:30
持续时间
2 小时
主持人
参赛人数
9