Shuffle#12345

Shuffle

1 second
256 megabytes
Very hard

Given an array of non-negative integers of length .

Define the swap operation as follows:

For any array of length , define its cost by the maximum value of c_i + c_j for all such that 1 \leq i < j \leq n and gcd(i, j) > 1, or if no such exist.

Find an array of length such that can be obtained by any number of swap operations, and the cost of the array is minimal.

Input

The first line contains a single integer (1 \leq n \leq 10^6) — the length of the array .

The second line contains integers a_1, a_2, \ldots, a_n (0 \leq a_i \leq \textbf{3}) — the elements of array .

Output

Output a single line with integers — the elements of array . If there are multiple correct answers, any one of them is allowed.

Examples

Example 1

Loading
Loading

Scoring

  1. ( points): n \leq 10;

  2. ( points): n \leq 50; the answer can be obtained with at most one swap operation;

  3. ( points): n \leq 1\,000; the answer can be obtained with at most one swap operation;

  4. ( points): the answer can be obtained with at most one swap operation;

  5. ( points): \max(a_i) \leq 1; n \leq 1\,000;

  6. ( points): \max(a_i) \leq 1;

  7. ( points): \max(a_i) \leq 2; n \leq 1\,000;

  8. ( points): \max(a_i) \leq 2;

  9. ( points): n \leq 1\,000;

  10. ( points): without additional constraints.

In blocks with partial grading, your solution will receive half points if for all tests in that block your solution outputs an array where the cost either matches the correct solution or is more.