#K35232. Sum of Absolute Differences

    ID: 25486 Type: Default 1000ms 256MiB

Sum of Absolute Differences

Sum of Absolute Differences

You are given an integer N and a list of N integers. Your task is to compute the sum of the absolute differences between each pair of consecutive elements in the list. In other words, if the list is \(a_0, a_1, \ldots, a_{N-1}\), you need to calculate:

\(\sum_{i=1}^{N-1} |a_i - a_{i-1}|\)

Print the result to standard output.

inputFormat

The first line of input contains a single integer N, the number of elements in the list.

The second line contains N space-separated integers representing the list elements.

outputFormat

Output a single integer, which is the sum of the absolute differences between each pair of consecutive elements.

## sample
5
1 -3 4 -2 6
25

</p>