100 atcoder#ABC133D. [ABC133D] Rain Flows into Dams

[ABC133D] Rain Flows into Dams

Score : 400400 points

Problem Statement

There are NN mountains in a circle, called Mountain 11, Mountain 22, ......, Mountain NN in clockwise order. NN is an odd number.

Between these mountains, there are NN dams, called Dam 11, Dam 22, ......, Dam NN. Dam ii (1iN1 \leq i \leq N) is located between Mountain ii and i+1i+1 (Mountain N+1N+1 is Mountain 11).

When Mountain ii (1iN1 \leq i \leq N) receives 2x2x liters of rain, Dam i1i-1 and Dam ii each accumulates xx liters of water (Dam 00 is Dam NN).

One day, each of the mountains received a non-negative even number of liters of rain.

As a result, Dam ii (1iN1 \leq i \leq N) accumulated a total of AiA_i liters of water.

Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Constraints

  • All values in input are integers.
  • 3N10513 \leq N \leq 10^5-1
  • NN is an odd number.
  • 0Ai1090 \leq A_i \leq 10^9
  • The situation represented by input can occur when each of the mountains receives a non-negative even number of liters of rain.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 ...... ANA_N

Output

Print NN integers representing the number of liters of rain Mountain 11, Mountain 22, ......, Mountain NN received, in this order.

3
2 2 4
4 0 4

If we assume Mountain 11, 22, and 33 received 44, 00, and 44 liters of rain, respectively, it is consistent with this input, as follows:

  • Dam 11 should have accumulated 42+02=2\frac{4}{2} + \frac{0}{2} = 2 liters of water.
  • Dam 22 should have accumulated 02+42=2\frac{0}{2} + \frac{4}{2} = 2 liters of water.
  • Dam 33 should have accumulated 42+42=4\frac{4}{2} + \frac{4}{2} = 4 liters of water.
5
3 8 7 5 5
2 4 12 2 8
3
1000000000 1000000000 0
0 2000000000 0