100 atcoder#ABC143B. [ABC143B] TAKOYAKI FESTIVAL 2019

[ABC143B] TAKOYAKI FESTIVAL 2019

Score : 200200 points

Problem Statement

It's now the season of TAKOYAKI FESTIVAL!

This year, NN takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the ii-th takoyaki is did_i.

As is commonly known, when you eat two takoyaki of deliciousness xx and yy together, you restore x×yx \times y health points.

There are N×(N1)2\frac{N \times (N - 1)}{2} ways to choose two from the NN takoyaki served in the festival. For each of these choices, find the health points restored from eating the two takoyaki, then compute the sum of these N×(N1)2\frac{N \times (N - 1)}{2} values.

Constraints

  • All values in input are integers.
  • 2N502 \leq N \leq 50
  • 0di1000 \leq d_i \leq 100

Input

Input is given from Standard Input in the following format:

NN

d1d_1 d2d_2 ...... dNd_N

Output

Print the sum of the health points restored from eating two takoyaki over all possible choices of two takoyaki from the NN takoyaki served.

3
3 1 2
11

There are three possible choices:

  • Eat the first and second takoyaki. You will restore 33 health points.
  • Eat the second and third takoyaki. You will restore 22 health points.
  • Eat the first and third takoyaki. You will restore 66 health points.

The sum of these values is 1111.

7
5 0 7 8 3 3 2
312