#C9987. Generate Consecutive Sum Array

    ID: 54140 Type: Default 1000ms 256MiB

Generate Consecutive Sum Array

Generate Consecutive Sum Array

Given an array of n positive integers, generate a new array where each element is computed as follows:

  • For every index \( i \) (with \( 0 \leq i < n-1 \)), the new element is \( arr[i] + arr[i+1] \).
  • The last element remains unchanged.

In other words, if the original array is \( [a_0, a_1, \ldots, a_{n-1}] \), the generated new array is \[ [a_0+a_1, a_1+a_2, \dots, a_{n-2}+a_{n-1}, a_{n-1}] \]

You need to implement a program that reads input from stdin and writes the result to stdout.

inputFormat

The input consists of two lines:

  • The first line contains a single integer \( n \) (the number of elements in the array).
  • The second line contains \( n \) positive integers separated by spaces.

outputFormat

Output a single line containing the elements of the new array separated by a single space.

## sample
5
1 2 3 4 5
3 5 7 9 5