#C12610. Consecutive Differences

    ID: 42057 Type: Default 1000ms 256MiB

Consecutive Differences

Consecutive Differences

You are given a list of integers. Your task is to compute the consecutive differences of the list, i.e. for each adjacent pair \(a_i\) and \(a_{i+1}\), calculate \(a_{i+1} - a_i\). If the list contains fewer than 2 elements, output nothing.

Input Format: The first line contains an integer \(n\) denoting the number of elements in the list. The second line contains \(n\) space-separated integers.

Output Format: Print the consecutive differences separated by a single space. If there are no differences to compute, print nothing.

Example:

  • Input: 5\n1 2 3 4 5
  • Output: 1 1 1 1

inputFormat

The input consists of two lines:

  1. The first line contains a single integer \(n\) (\(0 \leq n \leq 10^5\)).
  2. The second line contains \(n\) integers separated by spaces.

Note: If \(n < 2\), there is no output.

outputFormat

Output a single line containing the consecutive differences of the input list, separated by a single space. If no differences exist (i.e. when \(n < 2\)), output nothing.

## sample
5
1 2 3 4 5
1 1 1 1