CF1006A.Adjacent Replacements

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Adjacent Replacements

Mishka got an integer array aa of length nn as a birthday present (what a surprise!).

Mishka doesn't like this present and wants to change it somehow. He has invented an algorithm and called it "Mishka's Adjacent Replacements Algorithm". This algorithm can be represented as a sequence of steps:

  • Replace each occurrence of 11 in the array aa with 22;
  • Replace each occurrence of 22 in the array aa with 11;
  • Replace each occurrence of 33 in the array aa with 44;
  • Replace each occurrence of 44 in the array aa with 33;
  • Replace each occurrence of 55 in the array aa with 66;
  • Replace each occurrence of 66 in the array aa with 55;
  • \dots
  • Replace each occurrence of 109110^9 - 1 in the array aa with 10910^9;
  • Replace each occurrence of 10910^9 in the array aa with 109110^9 - 1.

Note that the dots in the middle of this algorithm mean that Mishka applies these replacements for each pair of adjacent integers (2i1,2i2i - 1, 2i) for each i{1,2,,5108}i \in\{1, 2, \ldots, 5 \cdot 10^8\} as described above.

For example, for the array a=[1,2,4,5,10]a = [1, 2, 4, 5, 10], the following sequence of arrays represents the algorithm:

[1,2,4,5,10][1, 2, 4, 5, 10] \rightarrow (replace all occurrences of 11 with 22) \rightarrow [2,2,4,5,10][2, 2, 4, 5, 10] \rightarrow (replace all occurrences of 22 with 11) \rightarrow [1,1,4,5,10][1, 1, 4, 5, 10] \rightarrow (replace all occurrences of 33 with 44) \rightarrow [1,1,4,5,10][1, 1, 4, 5, 10] \rightarrow (replace all occurrences of 44 with 33) \rightarrow [1,1,3,5,10][1, 1, 3, 5, 10] \rightarrow (replace all occurrences of 55 with 66) \rightarrow [1,1,3,6,10][1, 1, 3, 6, 10] \rightarrow (replace all occurrences of 66 with 55) \rightarrow [1,1,3,5,10][1, 1, 3, 5, 10] \rightarrow \dots \rightarrow [1,1,3,5,10][1, 1, 3, 5, 10] \rightarrow (replace all occurrences of 1010 with 99) \rightarrow [1,1,3,5,9][1, 1, 3, 5, 9]. The later steps of the algorithm do not change the array.

Mishka is very lazy and he doesn't want to apply these changes by himself. But he is very interested in their result. Help him find it.

Input

The first line of the input contains one integer number nn (1n10001 \le n \le 1000) — the number of elements in Mishka's birthday present (surprisingly, an array).

The second line of the input contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai1091 \le a_i \le 10^9) — the elements of the array.

Output

Print nn integers — b1,b2,,bnb_1, b_2, \dots, b_n, where bib_i is the final value of the ii-th element of the array after applying "Mishka's Adjacent Replacements Algorithm" to the array aa. Note that you cannot change the order of elements in the array.

Note

The first example is described in the problem statement.

Samples

5
1 2 4 5 10
1 1 3 5 9
10
10000 10 50605065 1 5 89 5 999999999 60506056 1000000000
9999 9 50605065 1 5 89 5 999999999 60506055 999999999

在线编程 IDE

建议全屏模式获得最佳体验