Fenwick Tree
문제
Fenwick tree is a data structure effectively supporting prefix sum queries.
For a number denote as maximal such that is divisible by . For example, , . Let , for example, .
Consider array of integer numbers. Fenwick tree for this array is the array such that
So
For example, the Fenwick tree for the array a = (3,−1,4,1,−5,9) is the array b = (3,2,4,7,−5,4)\text{.}
Let us call an array self-fenwick if it coincides with its Fenwick tree. For example, the array above is not self-fenwick, but the array a = (0, −1, 1, 1, 0, 9) is self-fenwick.
You are given an array a. You are allowed to change values of some elements without changing their order to get a new array a′ which must be self-fenwick. Find the way to do it by changing as few elements as possible.
입력
The first line of the input file contains n — the number of elements in the array (1 ≤ n ≤ 100 000). The second line contains n integer numbers — the elements of the array. The elements do not exceed 109 by their absolute values.
출력
Output n numbers — the elements of the array a′. If there are several solutions, output any one.
예제
예제 1
6 3 -1 4 1 -5 9
0 -1 1 1 0 9