atcoder#ARC153C. [ARC153C] ± Increasing Sequence

[ARC153C] ± Increasing Sequence

Score : 600600 points

Problem Statement

You are given a sequence of length NN, A=(A1,,AN)A = (A_1, \ldots, A_N), consisting of 11 and 1-1.

Determine whether there is an integer sequence x=(x1,,xN)x = (x_1, \ldots, x_N) that satisfies all of the following conditions, and print one such sequence if it exists.

  • xi1012|x_i| \leq 10^{12} for every ii (1iN1\leq i\leq N).
  • xx is strictly increasing. That is, x1<<xNx_1 < \cdots < x_N.
  • i=1NAixi=0\sum_{i=1}^N A_ix_i = 0.

Constraints

  • 1N2×1051\leq N\leq 2\times 10^5
  • Ai{1,1}A_i \in \lbrace 1, -1\rbrace

Input

The input is given from Standard Input in the following format:

NN

A1A_1 \ldots ANA_N

Output

If there is an integer sequence xx that satisfies all of the conditions in question, print Yes; otherwise, print No. In case of Yes, print the elements of such an integer sequence xx in the subsequent line, separated by spaces.

x1x_1 \ldots xNx_N

If multiple integer sequences satisfy the conditions, you may print any of them.

5
-1 1 -1 -1 1
Yes
-3 -1 4 5 7

For this output, we have i=1NAixi=(3)+(1)45+7=0\sum_{i=1}^NA_ix_i= -(-3) + (-1) - 4 - 5 + 7 = 0.

1
-1
Yes
0
2
1 -1
No