#K65097. Consecutive Differences

    ID: 32121 Type: Default 1000ms 256MiB

Consecutive Differences

Consecutive Differences

Given a list of integers, compute a new list of integers where each element is the difference between consecutive elements of the original list. Formally, if the input list is \(a_0, a_1, \dots, a_{n-1}\), then the output should be \(a_1 - a_0, a_2 - a_1, \dots, a_{n-1} - a_{n-2}\). This problem requires reading input from the standard input (stdin) and printing the result to the standard output (stdout).

inputFormat

The first line of input contains an integer (n) ((n \ge 2)), which represents the number of elements in the list. The second line contains (n) space-separated integers, representing the elements of the list.

outputFormat

Output a single line containing (n-1) space-separated integers. Each integer is the difference between consecutive elements in the list.## sample

4
3 8 1 5
5 -7 4