#C9889. List Neighbor Sum Transformation
List Neighbor Sum Transformation
List Neighbor Sum Transformation
This problem requires you to transform a list of integers by adding each element with its neighbors. For each position i in the list, the new value is given by:
\( result[i] = lst[i] + (\text{if exists } lst[i-1] \text{ else } 0) + (\text{if exists } lst[i+1] \text{ else } 0) \).
For example, if the input list is [1, 2, 3], the output will be [3, 6, 5]. The transformation takes care of edge elements by assuming a missing neighbor is 0.
You need to implement a program that reads the input from stdin and outputs the transformed list to stdout with the elements separated by a single space.
inputFormat
The first line contains a single integer n (\( 0 \leq n \leq 10^5 \)), the number of elements in the list.
The second line contains n space-separated integers representing the list.
outputFormat
Output a single line with the transformed list. The numbers should be space-separated.
## sample3
1 2 3
3 6 5