#C11987. Accumulated Product of Differences

    ID: 41363 Type: Default 1000ms 256MiB

Accumulated Product of Differences

Accumulated Product of Differences

Problem Description:

Given a list of integers, compute the Accumulated Product of Differences (APD) of the list. The APD is defined as follows:

[ APD = \begin{cases} 1, & \text{if } n < 2,\ \prod_{i=1}^{n-1} \left|a_i - a_{i-1}\right|, & \text{if } n \ge 2. \end{cases} ]

For example, for the array [5, 3, 8, 6]:
[ APD = |3-5| \times |8-3| \times |6-8| = 2 \times 5 \times 2 = 20. ]

Your task is to read the input from standard input (stdin) and print the result to standard output (stdout).

inputFormat

Input Format:

The first line contains an integer (N), representing the number of elements in the array. The second line contains (N) space-separated integers.

outputFormat

Output Format:

Print a single integer, which is the Accumulated Product of Differences of the array.## sample

4
5 3 8 6
20