#ARC135B. [ARC135B] Sum of Three Terms

[ARC135B] Sum of Three Terms

Score : 500500 points

Problem Statement

You are given a sequence of NN integers S=(S1,,SN)S = (S_1, \ldots, S_N). Determine whether there is a sequence of N+2N+2 integers A=(A1,,AN+2)A = (A_1, \ldots, A_{N+2}) that satisfies the conditions below.

  • 0Ai0\leq A_i for every ii (1iN+21\leq i\leq N+2).
  • Si=Ai+Ai+1+Ai+2S_i = A_{i} + A_{i+1} + A_{i+2} for every ii (1iN1\leq i\leq N).

If it exists, print one such sequence.

Constraints

  • 1N3×1051\leq N\leq 3\times 10^5
  • 0Si1090\leq S_i\leq 10^9

Input

Input is given from Standard Input from the following format:

NN

S1S_1 \ldots SNS_N

Output

If there is a sequence AA that satisfies the conditions, print Yes; otherwise, print No. In the case of Yes, print an additional line containing the elements of such a sequence AA, separated by spaces.

A1A_1 \ldots AN+2A_{N+2}

If there are multiple sequences satisfying the conditions, you may print any of them.

5
6 9 6 6 5
Yes
0 4 2 3 1 2 2

We can verify that Si=Ai+Ai+1+Ai+2S_i = A_i + A_{i+1} + A_{i+2} for every ii (1iN1\leq i\leq N), as follows.

  • 6=0+4+26 = 0 + 4 + 2.
  • 9=4+2+39 = 4 + 2 + 3.
  • 6=2+3+16 = 2 + 3 + 1.
  • 6=3+1+26 = 3 + 1 + 2.
  • 5=1+2+25 = 1 + 2 + 2.
5
0 1 2 1 0
No
1
10
Yes
0 0 10