#C10192. Exciting Energy

    ID: 39370 Type: Default 1000ms 256MiB

Exciting Energy

Exciting Energy

Villagers exchange high-fives, and each high-five generates excitement energy. You are given an integer \(n\) (with \(n \geq 2\)) representing the number of villagers, and a sequence of \(n\) positive integers \(s_1, s_2, \dots, s_n\) representing the high-five strength of each villager. The total excitement energy is defined as:

\[ E = \sum_{i=1}^{n-1} s_i \times s_{i+1} \]

Your task is to compute \(E\) given the sequence of strengths.

inputFormat

The input is given from standard input (stdin) and consists of two lines:

  • The first line contains a single integer \(n\) (\(n \geq 2\)), the number of villagers.
  • The second line contains \(n\) space-separated integers \(s_1, s_2, \dots, s_n\), representing the high-five strengths of the villagers.

outputFormat

Output to standard output (stdout) a single integer, which is the total excitement energy calculated as \(E = \sum_{i=1}^{n-1} s_i \times s_{i+1}\).

## sample
4
1 2 3 4
20

</p>