atcoder#ARC128A. [ARC128A] Gold and Silver

[ARC128A] Gold and Silver

Score : 400400 points

Problem Statement

Snuke has 11 gram of gold and 00 grams of silver now. He will do trading of gold and silver for the following NN days. On each day, he has two choices: do nothing, or make a trade. If he trades on Day ii (1iN1 \leq i \leq N), the following will happen.

  • If he has xx grams of gold before the trade, exchange all of it for x×Aix \times A_i grams of silver. On the other hand, if he has xx grams of silver, exchange all of it for x/Aix / A_i grams of gold.

Snuke's objective is to maximize the amount of gold he has in the end. Find one way to achieve his objective.

Constraints

  • 2N2000002 \leq N \leq 200000
  • 1Ai1091 \leq A_i \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \cdots ANA_N

Output

Print the answer in the following format:

v1v_1 v2v_2 \cdots vNv_N

Here, viv_i is an integer representing the action on Day ii (0vi10 \leq v_i \leq 1). vi=0v_i=0 means he does nothing, and vi=1v_i=1 means he makes a trade. If there are multiple possible solutions, printing any of them will be considered correct.

3
3 5 2
0 1 1

The optimal sequence of actions is as follows.

  • Day 11: Do nothing.
  • Day 22: Exchange 11 gram of gold for 55 grams of silver.
  • Day 33: Exchange 55 grams of silver for 2.52.5 grams of gold.
4
1 1 1 1
0 0 0 0

(v1,v2,v3,v4)=(1,1,1,1)(v_1,v_2,v_3,v_4)=(1,1,1,1), for example, is also considered correct.

10
426877385 186049196 624834740 836880476 19698398 709113743 436942115 436942115 436942115 503843678
1 1 0 1 1 1 1 0 0 0