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.

限制

  • 时间限制:1s1s
  • 空间限制:256M256M

题目描述

给你一个数列 A=(A1,A2,,AN)A=(A_1,A_2,\cdots,A_N)

我们定义他们的魅力值为1i<jNAiAj\sum\limits_{1\le i<j\le N} A_iA_j,现在要求你求这个数列的魅力值

输入格式

第一行一个整数 N(2N3×105)N(2\le N\le 3\times 10^5)。 第二行 NN 个整数 A1,A2,,AN(1Ai104)A_1,A_2,\cdots,A_N(1\le A_i\le 10^4)

输出格式

一行一个整数表示答案。

样例1

输入

3
4 2 3

输出

26

样例2

输入

2
9 45

输出

405

样例解释

$\sum\limits_{1\le i<j\le N} A_iA_j=A_1A_2+A_1A_3+A_2A_3=4\times 2+4\times 3+2\times 3=26$。

数据分布

40% 40\% 的样例,N(2N100)N(2\le N\le 100)A1,A2,,AN(1Ai100)A_1,A_2,\cdots,A_N(1\le A_i\le 100)

100% 100\% 的样例,N(2N3×105)N(2\le N\le 3\times 10^5)A1,A2,,AN(1Ai104)A_1,A_2,\cdots,A_N(1\le A_i\le 10^4)