#K42272. Array Compression
Array Compression
Array Compression
A software company has developed a new compression algorithm for arrays. The algorithm works by replacing each element in an array with the sum of its neighboring elements, including itself. In detail, for each index \(i\) (with \(1 \leq i \leq N-2\)), the new value will be \(arr[i-1] + arr[i] + arr[i+1]\). The first and last elements are special cases: the first element becomes \(arr[0] + arr[1]\) and the last element becomes \(arr[N-2] + arr[N-1]\). When the array consists of only one element, the output remains unchanged.
Your task is to apply this compression algorithm exactly once and output the resulting array.
inputFormat
The input is given from standard input (stdin) and consists of two lines. The first line contains an integer (N) ((1 \leq N \leq 10^5)) representing the number of elements in the array. The second line contains (N) space-separated integers representing the array elements.
outputFormat
Print a single line to standard output (stdout) containing (N) space-separated integers representing the compressed array after applying the algorithm exactly once.## sample
5
1 2 3 4 5
3 6 9 12 9