CR08C2P5 - KEMIJA
Instead of paying attention in chemistry class, Luka is killing time playing with numbers again. This time, he wrote N positive integers so that they form a ring (circle). After that he formed a new ring by adding to each number its two neighbours. The teacher noticed this and took away the first piece of paper, with the original ring. This did not trouble Luka much because he knows he can use the other ring to reconstruct the original. Write a program that solves Luka's problem.
Input
The first line contains the integer N (3 ≤ N ≤ 10000), the number of integers in the rings. Each of the following N lines contains an integer less than 109 (one billion). These numbers, in order, form the second ring. The input will be such that a solution, although not necessarily unique, will always exist.
Output
Output the original ring on N lines. The numbers must be positive. Rotating the ring is not allowed. For example, the sum of the first three output numbers must be equal to the second number in the input ring. Note: The solution need not be unique.
Example
Input: 3 5 5 5 Output: 2 1 2
Input: 4 20 15 17 14 Output: 5 8 2 7
Input: 5 7 8 9 10 11 Output: 4 1 3 5 2
Added by: | Ahmed Salem [mrtempo] |
Date: | 2015-01-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 JS-MONKEY |
Resource: | COCI 2007/2008 #2 (http://hsin.hr/coci/archive/2007_2008/contest2_tasks.pdf) |