#C13806. Absolute Differences in Consecutive Integers

    ID: 43385 Type: Default 1000ms 256MiB

Absolute Differences in Consecutive Integers

Absolute Differences in Consecutive Integers

Given a list of integers (a_0, a_1, \dots, a_{n-1}), your task is to compute a new list (b) defined as follows:

[ b_i = \begin{cases} |a_i - a_{i+1}|, & \text{for } 0 \le i < n-1, \ a_{n-1}, & \text{for } i = n-1. \end{cases} ]

If the input list is empty (i.e. (n=0)), output an empty list. The input is read from standard input and the output should be printed to standard output.

inputFormat

The first line contains an integer (n) representing the number of elements in the list. If (n > 0), the second line contains (n) space-separated integers representing the list.

outputFormat

Print the resulting list of integers as space-separated values on a single line. If the list is empty, print nothing.## sample

4
2 4 6 8
2 2 2 8