#P7703. Zero-Sum Weighted Sign Sequence

    ID: 20890 Type: Default 1000ms 256MiB

Zero-Sum Weighted Sign Sequence

Zero-Sum Weighted Sign Sequence

Given an integer \(N\) and a sequence of non-negative integers \(a_1, a_2, \dots, a_N\), you are required to find any integer sequence \(b_1, b_2, \dots, b_N\) that meets the following conditions:

  • Each \(b_i\) is an integer with \(|b_i| \leq 1\) (i.e. \(b_i \in \{-1, 0, 1\}\)).
  • The sequence is not all zeros: \(\sum_{i=1}^{N} |b_i| \neq 0\).
  • The weighted sum is zero: \(\sum_{i=1}^{N} a_i b_i = 0\).

If there are multiple valid sequences, you may output any one of them.

inputFormat

The first line contains a single integer \(N\) (the length of the sequence). The second line contains \(N\) non-negative integers \(a_1, a_2, \dots, a_N\) separated by spaces.

outputFormat

Output \(N\) integers \(b_1, b_2, \dots, b_N\) separated by spaces. They must satisfy \(|b_i| \leq 1\), \(\sum_{i=1}^{N} |b_i| \neq 0\), and \(\sum_{i=1}^{N} a_i b_i = 0\).

sample

3
0 5 7
1 0 0

</p>