Under construction

Still being built. Things may change

Equations

Time limit1sMemory limit1024 MB

Summary
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 NN 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 NN, 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 NN, the count of numbers Karlas thought of. Each of the next N−1N-1 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 NN lines, one of Karlas's numbers per line, in order.

Constraints

  • 3≤N≤1,000,0003 \le N \le 1{,}000{,}000
  • Each number is a non-negative integer not exceeding 1,000,000,0001{,}000{,}000{,}000.

Examples3

  1. Example 1

    Input
    4
    7
    3
    10
    14
    
    Expected output
    4
    0
    7
    3
    
  2. Example 2

    Input
    3
    4
    5
    6
    
    Expected output
    1
    2
    3
    
  3. Example 3

    Input
    5
    60
    70
    80
    90
    150
    
    Expected output
    10
    20
    30
    40
    50