Unique Solution

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Professor is preparing a task for higher math students.

The task is the following. The students are given nn integers x_1,x_2,,x_nx\_1, x\_2, \ldots, x\_n, and an integer mm (1m<2n1 \le m < 2^n).

The student must choose nn integers a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n, each either 1-1, 00, or 11, at least one non-zero value be chosen. The chosen integers must satisfy the condition that a_1x_1+a_2x_2++a_nx_na\_1x\_1+a\_2x\_2+\ldots+a\_nx\_n is divisible by mm.

The professor has decided that the answer to the task should be some given array of integers a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n (1a_i1-1 \le a\_i \le 1, at least one of them is not equal to 00). To make his job of checking students' solutions easier, he wants to choose such integers x_1,x_2,,x_nx\_1, x\_2, \ldots, x\_n and an integer mm, that his array a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n is the only possible solution. Unfortunately it is not possible, because the array a_1,a_2,,a_n-a\_1, -a\_2, \ldots, -a\_n is always a solution too.

So the professor relaxes his requirements, and wants the only two solutions be a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n and a_1,a_2,,a_n-a\_1, -a\_2, \ldots, -a\_n

Help him choose integers x_1,x_2,,x_nx\_1, x\_2, \ldots, x\_n and an integer mm.

입력

The first line of input contains an integer nn (1n301 \leq n \leq 30).

The next line contains nn integers a_1,a_2,,a_na\_1, a\_2, \ldots, a\_n (1a_i1-1 \leq a\_i \leq 1). At least one of a_ia\_i is not equal to 00.

출력

The first line of output must contain and integer mm (1m<2n1 \le m < 2^n).

The next line must contain nn integers x_1,x_2,,x_nx\_1, x\_2, \ldots, x\_n (230<x_i<230-2^{30} < x\_i < 2^{30}).

If there are several possible answers, output any of them.

It is known that the answer always exists.

힌트

In the given example the students must choose a_1a\_1 and a_2a\_2 so that a_1+4a_2a\_1 + 4a\_2 is divisible by 33. There are two possible solutions: 

  • a_1=1a\_1 = 1, a_1=1a\_1 = -1 (a_1+4a_2=14=3a\_1 + 4a\_2 = 1 - 4 = -3, divisible by 33) and 
  • a_1=1a\_1 = -1, a_2=1a\_2 = 1 (a_1+4a_2=1+4=3a\_1 + 4a\_2 = -1 + 4 = 3, divisible by 33).

Professor's requirements are met.