Equations
Time limit1sMemory limit1024 MB
Given sums of each number paired with the last number, plus the total sum, recover all N original numbers.
- Level
Easy3 of 10
- Topics
- Math, Implementation, Prefix sum
- Solved
- No attempts yet
Problem
Karlas thought of non-negative integers. He told his friend Gustavas the sum of the first and the last number, the sum of the second and the last, the sum of the third and the last, and so on, up to the sum of the second-to-last and the last.
He also told Gustavas the sum of all the numbers. Karlas is very good at arithmetic, so from the information he gave, his numbers can always be recovered uniquely.
Given , the sums described above (first and last, second and last, and so on), and the sum of all the numbers, help Gustavas find the numbers Karlas thought of.
Input
The first line contains , the count of numbers Karlas thought of. Each of the next lines contains, in order, the sum of the first and the last number, the sum of the second and the last, and so on. The last line contains the sum of all the numbers he thought of.
Output
Output lines, one of Karlas's numbers per line, in order.
Constraints
- Each number is a non-negative integer not exceeding .