B. Neural Network
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

A Neural Network is a powerful Machine Learning technique that is inspired by the human brain. A Neural Network consists of several layers of nodes where information is passed through edges connecting the nodes.

More specifically, Akash is working with a Neural Network with $$$n$$$ layers, where the $$$i$$$-th layer has $$$a_i$$$ nodes. For every two adjacent layers, there is an edge connecting all pairs of nodes between one layer to the other layer. In other words, if two layers have $$$x$$$ and $$$y$$$ nodes, respectively, then a total of $$$x \cdot y$$$ edges will connect those layers.

Given the structure of his Neural Network, find the total number of edges needed to connect each pair of adjacent layers.

Input

The first line of the input will contain $$$n$$$ ($$$1 \leq n \leq 1000$$$), the number of layers in the Neural Network.

The next line will contain the $$$n$$$ integers $$$a_1 \dots a_n$$$ ($$$1 \leq a_i \leq 1000$$$) representing the number of nodes in each layer.

Output

Print a single integer, the total number of edges needed.

Example
Input
4
3 5 2 7
Output
39
Note

In the sample test case, a total of $$$39$$$ edges are needed.

  • To connect layers $$$1$$$ and $$$2$$$, $$$3 \cdot 5 = 15$$$ edges are needed.
  • To connect layers $$$2$$$ and $$$3$$$, $$$5 \cdot 2 = 10$$$ edges are needed.
  • To connect layers $$$3$$$ and $$$4$$$, $$$2 \cdot 7 = 14$$$ edges are needed.

So the total number of edges needed is $$$15 + 10 + 14 = 39$$$.